From 12a4c83b639d1b462d1a94c621fecf9ced14d964 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 20:57:09 +0100 Subject: [PATCH 01/23] migrates to CircleCI 2.0 --- circle.yml | 60 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/circle.yml b/circle.yml index 0ec9f1c..979f316 100644 --- a/circle.yml +++ b/circle.yml @@ -1,22 +1,38 @@ -machine: - pre: - - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0 - - sudo apt-get install devscripts - services: - - docker - environment: - RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it - -test: - override: - - checkbashisms -f ./drun - - ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - - ./drun -x docker:1.10.0 docker version # should bind docker.sock - - ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 true' # should do inception in 2 levels - - ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 sh -c "./drun -x docker:1.10.0 true"' # should do inception in 3 levels - - ./drun -x mhart/alpine-node:5.12.0 node --version | grep 'v5.12.0' # should get version of node - - ./drun -xNA node --version | grep 'v7.7.1' # should read version from package.json with mhart/alpine-node-auto image - - ./drun -xNM slim node --version | grep 'v7.7.1' # should read version from package.json node:7.7.1-slim image - - echo '{"test":"passing"}' | ./drun -x stedolan/jq '.test' | grep '"passing"' # should pipe into command inside container - - echo '{"test":"passing"}' > test.json && ./drun -x stedolan/jq '.test' test.json | grep '"passing"' # should mount current directory - - ./drun -? +version: 2 +executorType: docker +containerInfo: + - image: docker:1.10.0 +stages: + build: + parallel: 1 + workDir: ~/drun + environment: + RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it + steps: + - type: checkout + - type: shell + command: | + sudo apt-get install devscripts + checkbashisms -f ./drun + - type: shell + command: checkbashisms -f ./drun + - type: shell + command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container + - type: shell + command: ./drun -x docker:1.10.0 docker version # should bind docker.sock + - type: shell + command: ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 true' # should do inception in 2 levels + - type: shell + command: ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 sh -c "./drun -x docker:1.10.0 true"' # should do inception in 3 levels + - type: shell + command: ./drun -x mhart/alpine-node:5.12.0 node --version | grep 'v5.12.0' # should get version of node + - type: shell + command: ./drun -xNA node --version | grep 'v7.7.1' # should read version from package.json with mhart/alpine-node-auto image + - type: shell + command: ./drun -xNM slim node --version | grep 'v7.7.1' # should read version from package.json node:7.7.1-slim image + - type: shell + command: echo '{"test":"passing"}' | ./drun -x stedolan/jq '.test' | grep '"passing"' # should pipe into command inside container + - type: shell + command: echo '{"test":"passing"}' > test.json && ./drun -x stedolan/jq '.test' test.json | grep '"passing"' # should mount current directory + - type: shell + command: ./drun -? From 9286cef28861104ef24ff6c79f919e2fa6f3e096 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:01:12 +0100 Subject: [PATCH 02/23] changes base image --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 979f316..ef28a4e 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,7 @@ version: 2 executorType: docker containerInfo: - - image: docker:1.10.0 + - image: ubuntu:14.04 stages: build: parallel: 1 From c705902482b7fd85d7e602c83caa875d492bfcf7 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:05:25 +0100 Subject: [PATCH 03/23] ubuntu needs cmd, maybe --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index ef28a4e..7cf288e 100644 --- a/circle.yml +++ b/circle.yml @@ -2,6 +2,7 @@ version: 2 executorType: docker containerInfo: - image: ubuntu:14.04 + cmd: ["/bin/bash"] stages: build: parallel: 1 From 4f12a5f02176f927fa39045f27029fd968962c2c Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:11:42 +0100 Subject: [PATCH 04/23] apk install dependencies --- circle.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/circle.yml b/circle.yml index 7cf288e..c9e3b82 100644 --- a/circle.yml +++ b/circle.yml @@ -1,22 +1,24 @@ version: 2 executorType: docker containerInfo: - - image: ubuntu:14.04 - cmd: ["/bin/bash"] + - image: docker:1.10.0 stages: + checkout: + workDir: ~/drun + steps: + - type: shell + command: apk -U add git + - type: checkout build: - parallel: 1 + parallel: 3 workDir: ~/drun environment: RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it steps: - - type: checkout - type: shell command: | - sudo apt-get install devscripts + apk -U add checkbashisms checkbashisms -f ./drun - - type: shell - command: checkbashisms -f ./drun - type: shell command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - type: shell From d6979377555dd4dff283e06eedb3ae0be4ebb002 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:21:26 +0100 Subject: [PATCH 05/23] no parallel, bitte --- circle.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/circle.yml b/circle.yml index c9e3b82..3efa5dd 100644 --- a/circle.yml +++ b/circle.yml @@ -3,12 +3,6 @@ executorType: docker containerInfo: - image: docker:1.10.0 stages: - checkout: - workDir: ~/drun - steps: - - type: shell - command: apk -U add git - - type: checkout build: parallel: 3 workDir: ~/drun @@ -16,9 +10,10 @@ stages: RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it steps: - type: shell - command: | - apk -U add checkbashisms - checkbashisms -f ./drun + command: apk -U add git checkbashisms + - type: checkout + - type: shell + command: checkbashisms -f ./drun - type: shell command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - type: shell From c1525a2825850df2fba8296c62a8d8e80d1f4591 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:24:58 +0100 Subject: [PATCH 06/23] actually, set pwd --- circle.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 3efa5dd..c2a8b8c 100644 --- a/circle.yml +++ b/circle.yml @@ -2,6 +2,14 @@ version: 2 executorType: docker containerInfo: - image: docker:1.10.0 +stages: + checkout: + workDir: ~/drun + steps: + - type: shell + pwd: / + command: apk -U add git + - type: checkout stages: build: parallel: 3 @@ -10,10 +18,9 @@ stages: RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it steps: - type: shell - command: apk -U add git checkbashisms - - type: checkout - - type: shell - command: checkbashisms -f ./drun + command: | + apk -U add checkbashisms + checkbashisms -f ./drun - type: shell command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - type: shell From d1f7d298547da1656ade904452b11455757b6de3 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:26:30 +0100 Subject: [PATCH 07/23] ok, parallel --- circle.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/circle.yml b/circle.yml index c2a8b8c..7eee50b 100644 --- a/circle.yml +++ b/circle.yml @@ -8,19 +8,10 @@ stages: steps: - type: shell pwd: / - command: apk -U add git + command: apk -U add git checkbashisms - type: checkout -stages: - build: - parallel: 3 - workDir: ~/drun - environment: - RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it - steps: - type: shell - command: | - apk -U add checkbashisms - checkbashisms -f ./drun + command: checkbashisms -f ./drun - type: shell command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - type: shell From 67d96a4dd4f9197d570e32bd822fa91446eb02d9 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Wed, 15 Feb 2017 21:34:10 +0100 Subject: [PATCH 08/23] no tilde in path --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 7eee50b..ac82888 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ containerInfo: - image: docker:1.10.0 stages: checkout: - workDir: ~/drun + workDir: /home/circleci/drun steps: - type: shell pwd: / From c6f5462dc368a57cb2f787a2ef6afeea8b6bf195 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 11:34:00 +0100 Subject: [PATCH 09/23] re-adds removed env var --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index ac82888..a483525 100644 --- a/circle.yml +++ b/circle.yml @@ -5,6 +5,8 @@ containerInfo: stages: checkout: workDir: /home/circleci/drun + environment: + RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it steps: - type: shell pwd: / From 8e1748d2d2296674d7e7288b3f091d002dc50925 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:23:14 +0100 Subject: [PATCH 10/23] only build and deploy are allowed stage names --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index a483525..95d1c47 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ executorType: docker containerInfo: - image: docker:1.10.0 stages: - checkout: + build: workDir: /home/circleci/drun environment: RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it From ba2c7499743c07d5eecb56010cf79b9e42b95616 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:32:37 +0100 Subject: [PATCH 11/23] default shell is bash, which is not available --- circle.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 95d1c47..0622b77 100644 --- a/circle.yml +++ b/circle.yml @@ -10,7 +10,8 @@ stages: steps: - type: shell pwd: / - command: apk -U add git checkbashisms + shell: /bin/sh + command: apk --update add git checkbashisms - type: checkout - type: shell command: checkbashisms -f ./drun From 9b6d5008f6e633c8c54771f896f797c8dcf2fd9b Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:38:36 +0100 Subject: [PATCH 12/23] this is a little annoying --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 0622b77..6a8b686 100644 --- a/circle.yml +++ b/circle.yml @@ -11,7 +11,7 @@ stages: - type: shell pwd: / shell: /bin/sh - command: apk --update add git checkbashisms + command: apk --update add git openssh checkbashisms - type: checkout - type: shell command: checkbashisms -f ./drun From f1795e8072927df4f139501e464ccd225c7dd693 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:46:08 +0100 Subject: [PATCH 13/23] this is getting ridiculous --- circle.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/circle.yml b/circle.yml index 6a8b686..c1b7ce7 100644 --- a/circle.yml +++ b/circle.yml @@ -11,6 +11,9 @@ stages: - type: shell pwd: / shell: /bin/sh + command: ln -s /bin/sh /bin/bash + - type: shell + pwd: / command: apk --update add git openssh checkbashisms - type: checkout - type: shell From 0f91f05e38df73119be9dbcb516a6409c0a521a5 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:50:44 +0100 Subject: [PATCH 14/23] verbose, don't you think --- circle.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index c1b7ce7..6cff51e 100644 --- a/circle.yml +++ b/circle.yml @@ -11,30 +11,38 @@ stages: - type: shell pwd: / shell: /bin/sh - command: ln -s /bin/sh /bin/bash - - type: shell - pwd: / command: apk --update add git openssh checkbashisms - type: checkout - type: shell + shell: /bin/sh command: checkbashisms -f ./drun - type: shell + shell: /bin/sh command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container - type: shell + shell: /bin/sh command: ./drun -x docker:1.10.0 docker version # should bind docker.sock - type: shell + shell: /bin/sh command: ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 true' # should do inception in 2 levels - type: shell + shell: /bin/sh command: ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 sh -c "./drun -x docker:1.10.0 true"' # should do inception in 3 levels - type: shell + shell: /bin/sh command: ./drun -x mhart/alpine-node:5.12.0 node --version | grep 'v5.12.0' # should get version of node - type: shell + shell: /bin/sh command: ./drun -xNA node --version | grep 'v7.7.1' # should read version from package.json with mhart/alpine-node-auto image - type: shell + shell: /bin/sh command: ./drun -xNM slim node --version | grep 'v7.7.1' # should read version from package.json node:7.7.1-slim image - type: shell + shell: /bin/sh command: echo '{"test":"passing"}' | ./drun -x stedolan/jq '.test' | grep '"passing"' # should pipe into command inside container - type: shell + shell: /bin/sh command: echo '{"test":"passing"}' > test.json && ./drun -x stedolan/jq '.test' test.json | grep '"passing"' # should mount current directory - type: shell + shell: /bin/sh command: ./drun -? From 6628dcf8f87615946973e77a9640f69d20d8cde9 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 12:53:35 +0100 Subject: [PATCH 15/23] secret step type --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index 6cff51e..c143d14 100644 --- a/circle.yml +++ b/circle.yml @@ -16,6 +16,7 @@ stages: - type: shell shell: /bin/sh command: checkbashisms -f ./drun + - type: setup-docker-engine - type: shell shell: /bin/sh command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container From 6ce7558a4cf5c0bfea408266fc9d99651282727b Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 13:00:15 +0100 Subject: [PATCH 16/23] checks docker before checking drun --- circle.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index c143d14..1bb603d 100644 --- a/circle.yml +++ b/circle.yml @@ -19,7 +19,13 @@ stages: - type: setup-docker-engine - type: shell shell: /bin/sh - command: ./drun -x ubuntu:16.04 cat /etc/issue | grep 'Ubuntu 16.04' # should execute command inside container + command: docker version + - type: shell + shell: /bin/sh + command: ./drun -x alpine:3.5 date + - type: shell + shell: /bin/sh + command: ./drun -x alpine:3.5 cat /etc/issue | grep 'Alpine Linux 3.5' # should execute command inside container - type: shell shell: /bin/sh command: ./drun -x docker:1.10.0 docker version # should bind docker.sock From c12558e92406ffec05397c3394859066453ae660 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 13:03:49 +0100 Subject: [PATCH 17/23] debug --- drun | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drun b/drun index 6731f8b..5198068 100755 --- a/drun +++ b/drun @@ -120,10 +120,10 @@ if [ -f '/proc/1/cgroup' ]; then EXTRA_OPTS="${EXTRA_OPTS:-} --volumes-from $CURRENT_CONTAINER" # If current directory is inside any of the mounts of the current container - MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' ${CURRENT_CONTAINER}) - if [ "0" != $(echo "${CURRENT_DIR}" | grep ${MOUNTS}) ]; then - MAP_CURRENT_DIR_OPT='' - fi + # MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' ${CURRENT_CONTAINER}) + # if [ "0" != $(echo "${CURRENT_DIR}" | grep ${MOUNTS}) ]; then + # MAP_CURRENT_DIR_OPT='' + # fi fi fi From 3b1af0aca38bddf1fa282e778a6b65b9af6e5954 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 13:37:06 +0100 Subject: [PATCH 18/23] verifies if 'current container' exists, which it sometimes doesn't in CircleCI --- drun | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drun b/drun index 5198068..d757ff3 100755 --- a/drun +++ b/drun @@ -115,15 +115,15 @@ MAP_CURRENT_DIR_OPT="-v $CURRENT_DIR:$CONTAINER_HOME" # Inception detection if [ -f '/proc/1/cgroup' ]; then CURRENT_CONTAINER=$(grep '/docker/' -- /proc/1/cgroup | head -n1 | cut -d '/' -f 3) - if [ -n "${CURRENT_CONTAINER}" ]; then + if [ -n "${CURRENT_CONTAINER}" -a -z $(docker ps -q --filter "id=${CURRENT_CONTAINER}") ]; then # Maps volumes from current container EXTRA_OPTS="${EXTRA_OPTS:-} --volumes-from $CURRENT_CONTAINER" # If current directory is inside any of the mounts of the current container - # MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' ${CURRENT_CONTAINER}) - # if [ "0" != $(echo "${CURRENT_DIR}" | grep ${MOUNTS}) ]; then - # MAP_CURRENT_DIR_OPT='' - # fi + MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' ${CURRENT_CONTAINER}) + if [ "0" != $(echo "${CURRENT_DIR}" | grep ${MOUNTS}) ]; then + MAP_CURRENT_DIR_OPT='' + fi fi fi From 0904e42630bd65592ecd3311a07121799333f250 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 13:55:19 +0100 Subject: [PATCH 19/23] could docker ps and docker inspect disagree --- drun | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drun b/drun index d757ff3..4ed9d02 100755 --- a/drun +++ b/drun @@ -115,12 +115,12 @@ MAP_CURRENT_DIR_OPT="-v $CURRENT_DIR:$CONTAINER_HOME" # Inception detection if [ -f '/proc/1/cgroup' ]; then CURRENT_CONTAINER=$(grep '/docker/' -- /proc/1/cgroup | head -n1 | cut -d '/' -f 3) - if [ -n "${CURRENT_CONTAINER}" -a -z $(docker ps -q --filter "id=${CURRENT_CONTAINER}") ]; then + if [ -n "${CURRENT_CONTAINER}" ] && docker inspect --format='ok' "${CURRENT_CONTAINER}" 2>&1 > /dev/null; then # Maps volumes from current container EXTRA_OPTS="${EXTRA_OPTS:-} --volumes-from $CURRENT_CONTAINER" # If current directory is inside any of the mounts of the current container - MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' ${CURRENT_CONTAINER}) + MOUNTS=$(docker inspect --format='{{range .Mounts}} -e '{{.Destination}}'{{end}}' "${CURRENT_CONTAINER}") if [ "0" != $(echo "${CURRENT_DIR}" | grep ${MOUNTS}) ]; then MAP_CURRENT_DIR_OPT='' fi From b9fd7a8e357dd3f5943d7ee2f56b27b627326ba9 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 14:25:26 +0100 Subject: [PATCH 20/23] auto forward DOCKER_HOST env var --- drun | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drun b/drun index 4ed9d02..3174292 100755 --- a/drun +++ b/drun @@ -128,12 +128,14 @@ if [ -f '/proc/1/cgroup' ]; then fi DSOCK=/var/run/docker.sock -if [ "${MOUNTDOCKERSOCK:-}" != 'n' -a -r "$DSOCK" -a -w "$DSOCK" -a -S "$DSOCK" ]; then +if [ "${MOUNTDOCKERSOCK:-}" != 'n' -a -r "$DSOCK" -a -w "$DSOCK" -a -S "$DSOCK" ]; then if curl --help | grep -q unix-socket && curl -sS --unix-socket "$DSOCK" http://docker/_ping | grep -q OK; then EXTRA_OPTS="${EXTRA_OPTS:-} -v ${DSOCK}:${DSOCK}" elif nc -h 2>&1 | grep -qe '-X\b' && printf 'GET /_ping HTTP/1.1\nHost: daemon\n\n' | nc -U "$DSOCK" | head -n 1 | grep -q '200 OK'; then EXTRA_OPTS="${EXTRA_OPTS:-} -v ${DSOCK}:${DSOCK}" fi +elif [ -n "${DOCKER_HOST}" ]; then + EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_HOST=${DOCKER_HOST}" fi RM_OPT=${RM_OPT=--rm} From a1dbf3bc86f12ecfab18d0f24df1be6b6ac2389d Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Thu, 16 Feb 2017 14:52:10 +0100 Subject: [PATCH 21/23] also forwards DOCKER_TLS_VERIFY and DOCKER_CERT_PATH --- drun | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drun b/drun index 3174292..432d679 100755 --- a/drun +++ b/drun @@ -136,6 +136,8 @@ if [ "${MOUNTDOCKERSOCK:-}" != 'n' -a -r "$DSOCK" -a -w "$DSOCK" -a -S "$DSOCK" fi elif [ -n "${DOCKER_HOST}" ]; then EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_HOST=${DOCKER_HOST}" + EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_TLS_VERIFY=${DOCKER_TLS_VERIFY}" + EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_CERT_PATH=${DOCKER_CERT_PATH} -v ${DOCKER_CERT_PATH}:${DOCKER_CERT_PATH}:ro" fi RM_OPT=${RM_OPT=--rm} From 041c50934af6cbe2faed771626f641664b39255a Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Fri, 31 Mar 2017 17:33:37 -0300 Subject: [PATCH 22/23] no TLS verify --- drun | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drun b/drun index 432d679..d3f33cd 100755 --- a/drun +++ b/drun @@ -136,8 +136,7 @@ if [ "${MOUNTDOCKERSOCK:-}" != 'n' -a -r "$DSOCK" -a -w "$DSOCK" -a -S "$DSOCK" fi elif [ -n "${DOCKER_HOST}" ]; then EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_HOST=${DOCKER_HOST}" - EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_TLS_VERIFY=${DOCKER_TLS_VERIFY}" - EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_CERT_PATH=${DOCKER_CERT_PATH} -v ${DOCKER_CERT_PATH}:${DOCKER_CERT_PATH}:ro" + EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_TLS_VERIFY=0" fi RM_OPT=${RM_OPT=--rm} From 9c80466d9565a5ab612ccf8ae6bfb46471222879 Mon Sep 17 00:00:00 2001 From: JP Bochi Date: Fri, 31 Mar 2017 17:35:37 -0300 Subject: [PATCH 23/23] debug --- circle.yml => .circleci/config.yml | 25 +++++++++++++++++++------ drun | 10 ++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) rename circle.yml => .circleci/config.yml (74%) diff --git a/circle.yml b/.circleci/config.yml similarity index 74% rename from circle.yml rename to .circleci/config.yml index 1bb603d..94aed82 100644 --- a/circle.yml +++ b/.circleci/config.yml @@ -1,10 +1,10 @@ version: 2 -executorType: docker -containerInfo: - - image: docker:1.10.0 stages: build: - workDir: /home/circleci/drun + working_directory: /home/circleci/drun + machine: true + docker: + - image: docker:17.03.0 environment: RM_OPT: "" # tells drun not to --rm since CircleCI doesn't like it steps: @@ -19,7 +19,20 @@ stages: - type: setup-docker-engine - type: shell shell: /bin/sh - command: docker version + command: env + - type: shell + shell: /bin/sh + command: | + docker version + docker --help + docker info + docker --log-level debug ps + find /tmp/docker-* + mkdir -p /home/circleci/drun/.docker/ + cp ${DOCKER_CERT_PATH}/*.pem /home/circleci/drun/.docker/ + ls -lha /home/circleci/drun/.docker/ + ./drun -x alpine:3.5 ls -lha /home/circleci/drun/ + ./drun -x alpine:3.5 ls -lha /home/circleci/drun/.docker/ - type: shell shell: /bin/sh command: ./drun -x alpine:3.5 date @@ -28,7 +41,7 @@ stages: command: ./drun -x alpine:3.5 cat /etc/issue | grep 'Alpine Linux 3.5' # should execute command inside container - type: shell shell: /bin/sh - command: ./drun -x docker:1.10.0 docker version # should bind docker.sock + command: ./drun -x docker:17.03.0 docker version # should bind docker.sock - type: shell shell: /bin/sh command: ./drun -x docker:1.10.0 sh -c './drun -x docker:1.10.0 true' # should do inception in 2 levels diff --git a/drun b/drun index d3f33cd..2c5b4e7 100755 --- a/drun +++ b/drun @@ -111,9 +111,10 @@ if [ -n "${ENV_REGEX:-}" ]; then ENV_FILE_OPT="--env-file=$ENV_FILE" fi -MAP_CURRENT_DIR_OPT="-v $CURRENT_DIR:$CONTAINER_HOME" +MAP_CURRENT_DIR_OPT="-v $CURRENT_DIR/:$CONTAINER_HOME/" # Inception detection if [ -f '/proc/1/cgroup' ]; then + cat /proc/1/cgroup CURRENT_CONTAINER=$(grep '/docker/' -- /proc/1/cgroup | head -n1 | cut -d '/' -f 3) if [ -n "${CURRENT_CONTAINER}" ] && docker inspect --format='ok' "${CURRENT_CONTAINER}" 2>&1 > /dev/null; then # Maps volumes from current container @@ -135,8 +136,13 @@ if [ "${MOUNTDOCKERSOCK:-}" != 'n' -a -r "$DSOCK" -a -w "$DSOCK" -a -S "$DSOCK" EXTRA_OPTS="${EXTRA_OPTS:-} -v ${DSOCK}:${DSOCK}" fi elif [ -n "${DOCKER_HOST}" ]; then + # ARRRGH=$(echo $DOCKER_HOST | sed 's/tcp:/https:/') + # echo curl -ik "$ARRRGH"/_ping + # curl -ik "$ARRRGH"/_ping + # echo '--------' EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_HOST=${DOCKER_HOST}" - EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_TLS_VERIFY=0" + EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_TLS_VERIFY=1" + # EXTRA_OPTS="${EXTRA_OPTS:-} -e DOCKER_CERT_PATH=${DOCKER_CERT_PATH} -v ${DOCKER_CERT_PATH}/:${DOCKER_CERT_PATH}/:ro" fi RM_OPT=${RM_OPT=--rm}