Last active
August 23, 2018 15:21
-
-
Save rhizoome/e835a713263d93283d4e94202f760681 to your computer and use it in GitHub Desktop.
dcomp - accesses docker-containers from any directory, while keeping the directory (with bash-completion!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# stuff | |
if [ -f "/.docker-pwd" ]; then | |
cd $(cat /.docker-pwd) > /dev/null 2> /dev/null | |
fi | |
# other stuff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "edge" ]; then | |
export ALPINE_VERSION="$1" | |
else | |
export ALPINE_VERSION="v$1" | |
fi | |
cd /etc/apk | |
ln -s /var/cache/apk cache | |
cat > /etc/apk/repositories <<EOF | |
/home/ganwell/packages/community | |
/home/ganwell/packages/main | |
/home/ganwell/packages/testing | |
http://dl-cdn.alpinelinux.org/alpine/$ALPINE_VERSION/main | |
http://dl-cdn.alpinelinux.org/alpine/$ALPINE_VERSION/community | |
@test http://dl-cdn.alpinelinux.org/alpine/$ALPINE_VERSION/testing | |
EOF | |
apk update | |
apk upgrade | |
apk fix | |
apk add sudo abuild alpine-sdk ccache bash python3 ncurses || exit 1 | |
mkdir -p /usr/local/bin | |
cat >> /etc/sudoers <<EOF | |
ganwell ALL = NOPASSWD: /sbin/apk | |
EOF | |
rm -rf /var/cache/apk/* | |
rm /alpine_install.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function _docker_compose_cd { | |
pushd "$PWD" > /dev/null | |
cd "$HOME/compose" | |
_docker_compose | |
popd > /dev/null | |
} | |
complete -F _docker_compose_cd dcomp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
yum -y upgrade | |
yum -y groupinstall "Development Tools" | |
yum -y install epel-release | |
yum -y install python36 | |
ln -s /usr/bin/python36 /usr/bin/python3 | |
set +e | |
localedef -v -c -i de_CH -f UTF-8 de_CH.UTF-8 > /dev/null 2> /dev/null | |
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 > /dev/null 2> /dev/null | |
rm /centos_install.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "$PWD" > /dev/shm/.docker-pwd | |
export DOCKER_HOSTNAME="$(hostname)" | |
export DOCKER_UID="$(id -u):$(id -g)" | |
cd "$HOME/compose" | |
exec docker-compose "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get update | |
apt-get upgrade -y | |
apt-get install -y locales build-essential vim-nox git python3 bash-completion | |
apt-get clean | |
echo de_CH.UTF-8 UTF-8 >> /etc/locale.gen | |
echo en_US.UTF-8 UTF-8 >> /etc/locale.gen | |
locale-gen | |
rm /debian_install.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
x-default-conf: | |
&default-conf | |
user: ${DOCKER_UID} | |
hostname: ${DOCKER_HOSTNAME} | |
tty: true | |
x-default-env: | |
&default-env | |
XAUTHORITY: ${XAUTHORITY} | |
TERM: ${TERM} | |
DISPLAY: ${DISPLAY} | |
QT_X11_NO_MITSHM: 1 | |
XDG_SESSION_COOKIE: ${XDG_SESSION_COOKIE} | |
x-default-vol: | |
&default-vol | |
- /dev/shm/.docker-pwd:/.docker-pwd:ro | |
- /etc/passwd:/etc/passwd:ro | |
- /etc/group:/etc/group:ro | |
- /tmp/.X11-unix:/tmp/.X11-unix | |
- ${HOME}:${HOME} | |
x-alpine-vol: | |
&alpine-vol | |
- /dev/shm/.docker-pwd:/.docker-pwd:ro | |
- /etc/passwd:/etc/passwd:ro | |
- /etc/group:/etc/group:ro | |
- /tmp/.X11-unix:/tmp/.X11-unix | |
- /var/cache/apk:/var/cache/apk | |
- /etc/apk/keys:/etc/apk/keys | |
- ${HOME}:${HOME} | |
services: | |
alpine_latest: | |
build: | |
context: . | |
dockerfile: docker_alpine | |
args: | |
- DIST_VERSION=3.8 | |
<< : *default-conf | |
environment: | |
<< : *default-env | |
SHELLTOKEN: alpine-3.8 | |
volumes: *alpine-vol | |
alpine_edge: | |
build: | |
context: . | |
dockerfile: docker_alpine | |
args: | |
- DIST_VERSION=edge | |
user: ${DOCKER_UID} | |
hostname: ${DOCKER_HOSTNAME} | |
tty: true | |
environment: | |
<< : *default-env | |
SHELLTOKEN: alpine-edge | |
volumes: *alpine-vol | |
debian_sid: | |
build: | |
context: . | |
dockerfile: docker_debian | |
args: | |
- DIST_VERSION=sid | |
<< : *default-conf | |
environment: | |
<< : *default-env | |
SHELLTOKEN: debian-sid | |
volumes: | |
- /etc/passwd:/etc/passwd:ro | |
- /etc/group:/etc/group:ro | |
- /tmp/.X11-unix:/tmp/.X11-unix | |
- ${HOME}:${HOME} | |
debian_stretch: | |
build: | |
context: . | |
dockerfile: docker_debian | |
args: | |
- DIST_VERSION=stretch | |
<< : *default-conf | |
environment: | |
<< : *default-env | |
SHELLTOKEN: debian-stretch | |
volumes: *default-vol | |
debian_buster: | |
build: | |
context: . | |
dockerfile: docker_debian | |
args: | |
- DIST_VERSION=buster | |
<< : *default-conf | |
environment: | |
<< : *default-env | |
SHELLTOKEN: debian-buster | |
volumes: *default-vol | |
centos7: | |
build: | |
context: . | |
dockerfile: docker_centos | |
args: | |
- DIST_VERSION=7 | |
<< : *default-conf | |
environment: | |
<< : *default-env | |
SHELLTOKEN: centos7 | |
volumes: *default-vol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG DIST_VERSION=latest | |
FROM alpine:$DIST_VERSION | |
ADD alpine_install.sh / | |
ARG DIST_VERSION | |
RUN /alpine_install.sh $DIST_VERSION | |
ENTRYPOINT ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG DIST_VERSION=7 | |
FROM centos:$DIST_VERSION | |
ADD centos_install.sh / | |
RUN /centos_install.sh | |
ENTRYPOINT ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG DIST_VERSION=sid | |
FROM debian:$DIST_VERSION-slim | |
ADD debian_install.sh / | |
RUN /debian_install.sh | |
ENTRYPOINT ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the contents of the compose-dir: | |
$> ls $HOME/compose/ | cat | |
alpine_install.sh | |
centos_install.sh | |
debian_install.sh | |
docker-compose.yml | |
docker_alpine | |
docker_bger | |
docker_centos | |
docker_debian |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the shelltoken stuff is intermixed with my own prompt, just take what you want | |
# goes to .bashrc too | |
__env_ps1 () | |
{ | |
if command -v git >/dev/null; then | |
local git="$(git symbolic-ref HEAD 2>/dev/null)"; | |
fi | |
printf "[${git##refs/heads/}]"; | |
} | |
if [ ! -z "$SHELLTOKEN" ]; then | |
export SHELLTOKEN="$SHELLTOKEN " | |
fi | |
export -f __env_ps1 | |
export PS1="\[\033[00;34m\]$SHELLTOKEN\[\033]0;\u@\h: \w\007\]\[\033[00;32m\]\u\[\033[00;37m\]@\h \[\033[00;34m\]\w \$(__env_ps1 )\n\[\033[00;33m\]\$> \[\033[00m\]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dcomp exec -u 0 centos7 bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment