From 4f098d4fa8bd18a65b036e9879faec31e7259ca9 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Tue, 7 Aug 2018 19:59:59 -0500 Subject: [PATCH 1/5] tty workaround (side benefit: cleaner RUN scripts) --- Dockerfile | 5 ++++- README.md | 2 +- env/docker-entrypoint.sh | 1 + run.sh | 26 +++++++++++++++----------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11f3580..2ae92c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && dpkg-reconfigure locales \ && update-locale LANG=${__LANG} LANGUAGE=${__LANGUAGE} LC_ALL=${__LC_ALL} \ && unset DEBIAN_FRONTEND \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /usr/share/terminfo/d \ + && ln -s /lib/terminfo/d/dumb /usr/share/terminfo/d/dumb ENV LANG=${__LANG} SHELL ["/bin/sh", "-c"] @@ -93,6 +95,7 @@ ARG NPM_VERSION ARG NVM_VERSION SHELL ["/bin/bash", "-c"] RUN adduser --disabled-password --shell /bin/bash --gecos "" embark \ + && usermod -a -G tty embark \ && mkdir -p /dapp \ && chown embark:embark /dapp \ && curl -fsSLO --compressed "https://bootstrap.pypa.io/get-pip.py" \ diff --git a/README.md b/README.md index 7e42016..618015f 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ echo $1 # a comment echo $2 echo $3 -eval echo \\\$\$3 +eval echo \$$3 # another comment ``` Invoke with: diff --git a/env/docker-entrypoint.sh b/env/docker-entrypoint.sh index 92dd4b7..93d5259 100755 --- a/env/docker-entrypoint.sh +++ b/env/docker-entrypoint.sh @@ -3,4 +3,5 @@ export BASH_ENV=/home/embark/.bash_env chmod a+w /dev/std* +chmod g+r /dev/pts/0 exec su-exec embark user-entrypoint.sh "$@" diff --git a/run.sh b/run.sh index 8fb90fc..6f9b87f 100755 --- a/run.sh +++ b/run.sh @@ -141,17 +141,21 @@ run_embark () { fi local run_script=$(< "$EMBARK_DOCKER_RUN") -# do not add indentation to lines below - run_script="exec bash -s ${cmd[@]} << 'SCRIPT' -td=\$(mktemp -d) -cat << 'RUN' > \$td/run_script -$run_script -RUN -chmod +x \$td/run_script -exec \$td/run_script \$@ -SCRIPT -" -# do not add indentation to lines above + # do not alter indentation, tabs in lines below + run_script=$(cat <<- RUN_SCRIPT + exec bash -${i_flag}s \$(tty) ${cmd[@]} << 'SCRIPT' + __tty=\$1 + shift + td=\$(mktemp -d) + cat << 'RUN' > \$td/run_script + $run_script + RUN + chmod +x \$td/run_script + exec \$td/run_script \$@ < \$__tty + SCRIPT + RUN_SCRIPT + ) + # do not alter indentation, tabs in lines above cmd=( "bash" "-${i_flag}c" "$run_script" ) fi From 7e85f832d44283411c61d717738491c9b76c3cc2 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 8 Aug 2018 09:52:43 -0500 Subject: [PATCH 2/5] no need for mktemp -d flag; shuffle here-doc names --- run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index 6f9b87f..2b8efe3 100755 --- a/run.sh +++ b/run.sh @@ -143,16 +143,16 @@ run_embark () { local run_script=$(< "$EMBARK_DOCKER_RUN") # do not alter indentation, tabs in lines below run_script=$(cat <<- RUN_SCRIPT - exec bash -${i_flag}s \$(tty) ${cmd[@]} << 'SCRIPT' + exec bash -${i_flag}s \$(tty) ${cmd[@]} << 'RUN' __tty=\$1 shift - td=\$(mktemp -d) - cat << 'RUN' > \$td/run_script + script=\$(mktemp) + cat << 'SCRIPT' > \$script $run_script - RUN - chmod +x \$td/run_script - exec \$td/run_script \$@ < \$__tty SCRIPT + chmod +x \$script + exec \$script \$@ < \$__tty + RUN RUN_SCRIPT ) # do not alter indentation, tabs in lines above From 27bd3ca3df4c01228692de005411662d77ffa9e8 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 8 Aug 2018 11:46:22 -0500 Subject: [PATCH 3/5] env vars in example don't need to be exported --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 618015f..fa4b549 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,12 @@ Many aspects of `run_embark`'s behavior can be overridden with environment variables, and that approach can be (optionally) combined with `docker build`. ``` shell -export EMBARK_DOCKER_IMAGE=statusim/embark -export EMBARK_DOCKER_TAG=develop -export EMBARK_DOCKERFILE='https://github.com/embark-framework/embark-docker.git#master' -export EMBARK_VERSION='embark-framework/embark#develop' -export NODE_VERSION=10.7.0 -export RUNNER='https://raw.githubusercontent.com/embark-framework/embark-docker/master/run.sh' +EMBARK_DOCKER_IMAGE=statusim/embark +EMBARK_DOCKER_TAG=develop +EMBARK_DOCKERFILE='https://github.com/embark-framework/embark-docker.git#master' +EMBARK_VERSION='embark-framework/embark#develop' +NODE_VERSION=10.7.0 +RUNNER='https://raw.githubusercontent.com/embark-framework/embark-docker/master/run.sh' docker build \ --build-arg EMBARK_VERSION=$EMBARK_VERSION \ From fc5984b298f85ab27eb6aeeb65da0bc7fe465598 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 8 Aug 2018 17:16:53 -0500 Subject: [PATCH 4/5] don't auto nac in .bash_env if a nodeenv env is already activated --- env/.bash_env | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/env/.bash_env b/env/.bash_env index 1f24db7..61bef7e 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -126,4 +126,6 @@ __versions_export () { } export -f __versions_export -nac default +if [[ ! -v NODE_VIRTUAL_ENV ]]; then + nac default +fi From 9fa8af73dcebf663631b2c38da3a4eb200db9c56 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 9 Aug 2018 14:26:21 -0500 Subject: [PATCH 5/5] always write RUN script to /tmp/run_embark_script, for easy inspection --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 2b8efe3..c8a2d6a 100755 --- a/run.sh +++ b/run.sh @@ -146,7 +146,7 @@ run_embark () { exec bash -${i_flag}s \$(tty) ${cmd[@]} << 'RUN' __tty=\$1 shift - script=\$(mktemp) + script=/tmp/run_embark_script cat << 'SCRIPT' > \$script $run_script SCRIPT