From 5da4a50e2faa8d05d0aba127b82368511f98676b Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:54:07 -0500 Subject: [PATCH 01/22] install specific ver of bash-it (using tag on fork which serves that purpose) --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ae92c7..f02ed12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ ARG __CODESET=UTF-8 ARG __LANG=en_US.${__CODESET} ARG __LANGUAGE=en_US:en ARG __LC_ALL=en_US.${__CODESET} +ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch ARG EMBARK_VERSION=3.1.5 @@ -87,6 +88,7 @@ FROM builder-base LABEL maintainer="Andre Medeiros " +ARG BASHIT_VERSION ARG EMBARK_VERSION ARG GANACHE_VERSION ARG NODE_VERSION @@ -105,8 +107,9 @@ RUN adduser --disabled-password --shell /bin/bash --gecos "" embark \ COPY --from=builder-ipfs /go-ipfs/ipfs /usr/local/bin/ USER embark WORKDIR /home/embark -RUN git clone --depth 1 \ - https://github.com/Bash-it/bash-it.git \ +RUN git clone --branch ${BASHIT_VERSION} \ + --depth 1 \ + https://github.com/michaelsbradleyjr/bash-it.git \ .bash_it 2> /dev/null \ && mkdir -p .bash_it/custom/themes/nodez \ && git clone --branch v${NVM_VERSION} \ @@ -143,6 +146,7 @@ ENV __CODESET=${__CODESET} \ __LANG=${__LANG} \ __LANGUAGE=${__LANGUAGE} \ __LC_ALL=${__LC_ALL} \ + BASHIT_VERSION=${BASHIT_VERSION} \ BUILDER_BASE_IMAGE=${BUILDER_BASE_IMAGE} \ BUILDER_BASE_TAG=${BUILDER_BASE_TAG} \ EMBARK_VERSION=${EMBARK_VERSION} \ From 6aa28ef3477e04fae104334b24dc8b61a3f6094d Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:55:54 -0500 Subject: [PATCH 02/22] swarm is now a separate download, not bundled in newer geth-all-tools --- Dockerfile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f02ed12..18a35da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.2.0 ARG NVM_VERSION=0.33.11 ARG SUEXEC_VERSION=0.2 +ARG SWARM_VERSION=0.3.1-225171a4 # multi-stage builder images # ------------------------------------------------------------------------------ @@ -81,6 +82,16 @@ RUN git clone --branch v${SUEXEC_VERSION} \ && cd su-exec \ && make +# ------------------------------------------------------------------------------ + +FROM builder-base as builder-swarm +ARG SWARM_VERSION +RUN export url="https://gethstore.blob.core.windows.net/builds" \ + && export platform="swarm-linux-amd64" \ + && curl -fsSLO --compressed "${url}/${platform}-${SWARM_VERSION}.tar.gz" \ + && tar -xvzf swarm* \ + && rm swarm*/COPYING + # final image # ------------------------------------------------------------------------------ @@ -142,6 +153,7 @@ ARG GETH_VERSION ARG IPFS_VERSION ARG MICRO_VERSION ARG SUEXEC_VERSION +ARG SWARM_VERSION ENV __CODESET=${__CODESET} \ __LANG=${__LANG} \ __LANGUAGE=${__LANGUAGE} \ @@ -156,7 +168,8 @@ ENV __CODESET=${__CODESET} \ MICRO_VERSION=${MICRO_VERSION} \ NODEENV_VERSION=${NODEENV_VERSION} \ NVM_VERSION=${NVM_VERSION} \ - SUEXEC_VERSION=${SUEXEC_VERSION} + SUEXEC_VERSION=${SUEXEC_VERSION} \ + SWARM_VERSION=${SWARM_VERSION} SHELL ["/bin/sh", "-c"] USER root WORKDIR /dapp @@ -171,6 +184,7 @@ EXPOSE 5001 8000 8080 8500 8545 8546 8555 8556 30301/udp 30303 COPY --from=builder-geth /geth-alltools* /usr/local/bin/ COPY --from=builder-micro /micro*/micro /usr/local/bin/ COPY --from=builder-suexec /su-exec/su-exec /usr/local/bin/ +COPY --from=builder-swarm /swarm* /usr/local/bin/ COPY env/docker-entrypoint.sh \ env/user-entrypoint.sh \ env/install-extras.sh \ From d7d9d7ac3231a86befc44aef227507fd9edd9c4e Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:56:59 -0500 Subject: [PATCH 03/22] use same ver of ganache-cli as spec'd in pkg.json of embark's develop branch --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 18a35da..10ad3d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,10 @@ ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch ARG EMBARK_VERSION=3.1.5 -ARG GANACHE_VERSION=6.1.4 ARG GETH_VERSION=1.8.11-dea1ce05 ARG IPFS_VERSION=0.4.15 ARG MICRO_VERSION=1.4.0 +ARG GANACHE_VERSION=6.1.0 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.2.0 From d4a2647628d2725d48fc87b7898484a47a321e73 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:57:56 -0500 Subject: [PATCH 04/22] master branch of embark-docker should spec 'latest' (released) ver of embark --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 10ad3d5..77a8b6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,10 @@ ARG __LC_ALL=en_US.${__CODESET} ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch -ARG EMBARK_VERSION=3.1.5 ARG GETH_VERSION=1.8.11-dea1ce05 ARG IPFS_VERSION=0.4.15 ARG MICRO_VERSION=1.4.0 +ARG EMBARK_VERSION=latest ARG GANACHE_VERSION=6.1.0 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 From affbe3c4e8419af478f33765998d6c2b2f7cf8a1 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:58:27 -0500 Subject: [PATCH 05/22] bump geth --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 77a8b6f..08cf412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,11 @@ ARG __LC_ALL=en_US.${__CODESET} ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch -ARG GETH_VERSION=1.8.11-dea1ce05 ARG IPFS_VERSION=0.4.15 ARG MICRO_VERSION=1.4.0 ARG EMBARK_VERSION=latest ARG GANACHE_VERSION=6.1.0 +ARG GETH_VERSION=1.8.13-225171a4 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.2.0 From ff382b369dd9cf1d77fe8be1e973d197aa82238e Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:58:36 -0500 Subject: [PATCH 06/22] bump ipfs --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 08cf412..41cd504 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,11 @@ ARG __LC_ALL=en_US.${__CODESET} ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch -ARG IPFS_VERSION=0.4.15 ARG MICRO_VERSION=1.4.0 ARG EMBARK_VERSION=latest ARG GANACHE_VERSION=6.1.0 ARG GETH_VERSION=1.8.13-225171a4 +ARG IPFS_VERSION=0.4.17 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.2.0 From 41f22ca40988f44f97fa0a49eab23d9bd3e8e125 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 10 Aug 2018 16:58:43 -0500 Subject: [PATCH 07/22] bump micro --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 41cd504..7b88d98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,11 @@ ARG __LC_ALL=en_US.${__CODESET} ARG BASHIT_VERSION=10-aug-2018 ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch -ARG MICRO_VERSION=1.4.0 ARG EMBARK_VERSION=latest ARG GANACHE_VERSION=6.1.0 ARG GETH_VERSION=1.8.13-225171a4 ARG IPFS_VERSION=0.4.17 +ARG MICRO_VERSION=1.4.1 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.2.0 From 4fb228d6fe76d66847df97226170eaa794456250 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 12 Aug 2018 21:25:09 -0500 Subject: [PATCH 08/22] bash aliases for `npm ls [-g] --depth=0` --- env/.bashrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/env/.bashrc b/env/.bashrc index 59179fb..730e542 100644 --- a/env/.bashrc +++ b/env/.bashrc @@ -5,3 +5,6 @@ export BASH_IT=${HOME}/.bash_it export BASH_IT_THEME="nodez" . ${BASH_IT}/bash_it.sh + +alias nld0='npm ls --depth=0' +alias nlgd0='npm ls -g --depth=0' From 08bd3291f56887eaa4ccb4c8c8f034f0942c6a1a Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 12 Aug 2018 21:25:48 -0500 Subject: [PATCH 09/22] npm ver could change apart from nac/denac,nvm so prompt should check --- env/nodez.theme.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env/nodez.theme.bash b/env/nodez.theme.bash index b5e4ff2..7aef893 100644 --- a/env/nodez.theme.bash +++ b/env/nodez.theme.bash @@ -34,6 +34,10 @@ __nodez_ne() { __nodez_nv() { if [[ -v NODE_VERSION ]]; then local nv="=${__nodez_char_node}${NODE_VERSION}" + local npm_version=$(npm --version) + if [[ "$npm_version" != "$NPM_VERSION" ]]; then + export NPM_VERSION=$npm_version + fi nv+="${__nodez_char_npm}${NPM_VERSION}]" echo "$nv" fi From 5b9a0d27a5eaed51788cc59259cabeabf097e425 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:51:34 -0500 Subject: [PATCH 10/22] run should forward env vars only if they're defined --- run.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index c8a2d6a..94767df 100755 --- a/run.sh +++ b/run.sh @@ -35,10 +35,24 @@ run_embark () { "30303:30303" "-v" "${EMBARK_DOCKER_MOUNT_SOURCE}:${EMBARK_DOCKER_MOUNT_TARGET}" - "-e" - "TERM" ) + if [[ -v LANG ]]; then + run_opts=( "${run_opts[@]}" "-e" "LANG" ) + fi + + if [[ -v LANGUAGE ]]; then + run_opts=( "${run_opts[@]}" "-e" "LANGUAGE" ) + fi + + if [[ -v LC_ALL ]]; then + run_opts=( "${run_opts[@]}" "-e" "LC_ALL" ) + fi + + if [[ -v TERM ]]; then + run_opts=( "${run_opts[@]}" "-e" "TERM" ) + fi + if [[ $EMBARK_DOCKER_RUN_RM = true ]]; then run_opts=( "${run_opts[@]}" "--rm" ) fi From 5442b0f88f651386eee7538425de9fd00a671147 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:52:06 -0500 Subject: [PATCH 11/22] auto cleanup on error, and cleanup when finished --- run.sh | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/run.sh b/run.sh index 94767df..8f72bfa 100755 --- a/run.sh +++ b/run.sh @@ -75,23 +75,22 @@ run_embark () { esac set +e + cleanup () { + local retval=$? + unset check_bash_version + unset check_docker + unset cleanup + eval "$oldopts" + return $retval + } + check_bash_version () { if [[ $BASH_VERSINFO -lt 4 ]]; then echo "$ERROR: this script requires Bash version >= 4.0" return 1 fi } - check_bash_version - - if [[ $? = 1 ]]; then - unset check_bash_version - eval "$oldopts" - if [[ "$0" != "$BASH_SOURCE" ]]; then - return 1 - else - exit 1 - fi - fi + check_bash_version || cleanup || return check_docker () { if ! type docker &> /dev/null; then @@ -99,18 +98,7 @@ run_embark () { return 127 fi } - check_docker - - if [[ $? = 127 ]]; then - unset check_bash_version - unset check_docker - eval "$oldopts" - if [[ "$0" != "$BASH_SOURCE" ]]; then - return 127 - else - exit 127 - fi - fi + check_docker || cleanup || return local had_run_opts=false local -a _run_opts=() @@ -176,21 +164,10 @@ run_embark () { docker run \ "${run_opts[@]}" \ "${EMBARK_DOCKER_IMAGE}:${EMBARK_DOCKER_TAG}" \ - "${cmd[@]}" + "${cmd[@]}" \ + || cleanup || return - local docker_exit_status=$? - - unset check_bash_version - unset check_docker - eval "$oldopts" - - if [[ $docker_exit_status != 0 ]]; then - if [[ "$0" != "$BASH_SOURCE" ]]; then - return $docker_exit_status - else - exit $docker_exit_status - fi - fi + cleanup } export -f run_embark From 28f12915f6ac60ce205028944a00e8b3d2922656 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:52:29 -0500 Subject: [PATCH 12/22] install less during build --- Dockerfile | 3 ++- env/install-extras.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7b88d98..280fb9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,8 @@ ARG __LC_ALL SHELL ["/bin/bash", "-c"] RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ - && apt-get install -y locales \ + && apt-get install -y less \ + locales \ && sed -i \ -e "s/# ${__LANG} ${__CODESET}/${__LANG} ${__CODESET}/" \ /etc/locale.gen \ diff --git a/env/install-extras.sh b/env/install-extras.sh index 26b4362..03d02f7 100755 --- a/env/install-extras.sh +++ b/env/install-extras.sh @@ -2,7 +2,6 @@ apt-get update apt-get install -y \ - less \ lsof \ net-tools \ parallel \ From 88d16564342438ff4613085d842f0819cca248ef Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:52:39 -0500 Subject: [PATCH 13/22] bump npm --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 280fb9d..076469b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ARG IPFS_VERSION=0.4.17 ARG MICRO_VERSION=1.4.1 ARG NODE_VERSION=8.11.3 ARG NODEENV_VERSION=1.3.2 -ARG NPM_VERSION=6.2.0 +ARG NPM_VERSION=6.4.0 ARG NVM_VERSION=0.33.11 ARG SUEXEC_VERSION=0.2 ARG SWARM_VERSION=0.3.1-225171a4 From e0143c086fc5da6f31ca05023f73916be14a09cc Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:56:01 -0500 Subject: [PATCH 14/22] more DRY --- Dockerfile | 3 +-- env/.bash_env | 20 ++++++++----------- env/.bash_env_nvm_load | 2 -- ...h_env_denac => .bash_env_unset_npm_config} | 0 4 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 env/.bash_env_nvm_load rename env/{.bash_env_denac => .bash_env_unset_npm_config} (100%) diff --git a/Dockerfile b/Dockerfile index 076469b..1c55c04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -192,8 +192,7 @@ COPY env/docker-entrypoint.sh \ /usr/local/bin/ COPY --chown=embark:embark \ env/.bash_env \ - env/.bash_env_denac \ - env/.bash_env_nvm_load \ + env/.bash_env_unset_npm_config \ env/.bashrc \ env/.npmrc \ /home/embark/ diff --git a/env/.bash_env b/env/.bash_env index 61bef7e..7079811 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -22,7 +22,7 @@ nac () { __denac return 1 fi - __versions_export + __versions alias denac='deactivate_node' alias deactivate_node='__denac' case $- in @@ -46,9 +46,8 @@ __denac () { if type deactivate_node &> /dev/null; then deactivate_node fi - . ${HOME}/.bash_env_denac - unset NODE_VERSION - unset NPM_VERSION + . "${HOME}/.bash_env_unset_npm_config" + __versions } export -f __denac @@ -64,7 +63,7 @@ nvm_load () { __nvm_mask () { case "$*" in unload*) __nvm_unload ;; - *) unalias nvm; nvm "$@"; alias nvm='__nvm_mask'; __versions_export ;; + *) unalias nvm; nvm "$@"; alias nvm='__nvm_mask'; __versions ;; esac } export -f __nvm_mask @@ -72,16 +71,14 @@ nvm_load () { export -f nvm_load __nvm_load () { - __nvm_unload __denac - . ${HOME}/.bash_env_nvm_load . ${HOME}/.nvm/nvm.sh &> /dev/null case $- in *i*) bash-it enable completion nvm &> /dev/null; \ . ${BASH_IT}/completion/available/nvm.completion.bash ;; esac if [[ $(which node) = "${HOME}/.nvm/versions/"* ]]; then - __versions_export + __versions case $- in *i*) __npm_completion ;; esac @@ -96,8 +93,7 @@ __nvm_unload () { if type nvm &> /dev/null; then nvm unload fi - unset NODE_VERSION - unset NPM_VERSION + __versions } export -f __nvm_unload @@ -114,7 +110,7 @@ simple_nodeenv () { } export -f simple_nodeenv -__versions_export () { +__versions () { if type node &> /dev/null; then local node_version=$(node --version) export NODE_VERSION=${node_version##v} @@ -124,7 +120,7 @@ __versions_export () { unset NPM_VERSION fi } -export -f __versions_export +export -f __versions if [[ ! -v NODE_VIRTUAL_ENV ]]; then nac default diff --git a/env/.bash_env_nvm_load b/env/.bash_env_nvm_load deleted file mode 100644 index b7d09cf..0000000 --- a/env/.bash_env_nvm_load +++ /dev/null @@ -1,2 +0,0 @@ -unset npm_config_prefix -unset NPM_CONFIG_PREFIX diff --git a/env/.bash_env_denac b/env/.bash_env_unset_npm_config similarity index 100% rename from env/.bash_env_denac rename to env/.bash_env_unset_npm_config From 9a2380c7dad2e3c20ed371aa927922c81aefc463 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:56:42 -0500 Subject: [PATCH 15/22] symmetry in un/load --- env/.bash_env | 1 + 1 file changed, 1 insertion(+) diff --git a/env/.bash_env b/env/.bash_env index 7079811..5c62db7 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -73,6 +73,7 @@ export -f nvm_load __nvm_load () { __denac . ${HOME}/.nvm/nvm.sh &> /dev/null + __nvm_unload case $- in *i*) bash-it enable completion nvm &> /dev/null; \ . ${BASH_IT}/completion/available/nvm.completion.bash ;; From ac25b34a9349fe8515f5f9332396e41ca219f857 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 17:57:29 -0500 Subject: [PATCH 16/22] more care re: quotes and paths --- env/.bash_env | 12 ++++++------ env/.bashrc | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/env/.bash_env b/env/.bash_env index 5c62db7..1b6a0a4 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -1,6 +1,6 @@ unset BASH_ENV -export PATH=${HOME}/.local/bin:$PATH +export PATH="${HOME}/.local/bin:$PATH" nac () { local txtbld=$(tput bold) @@ -17,7 +17,7 @@ nac () { fi __nvm_unload __denac - . ${HOME}/.local/nodeenv/$1/bin/activate + . "${HOME}/.local/nodeenv/$1/bin/activate" if [[ $? != 0 ]]; then __denac return 1 @@ -72,11 +72,11 @@ export -f nvm_load __nvm_load () { __denac - . ${HOME}/.nvm/nvm.sh &> /dev/null __nvm_unload + . "${HOME}/.nvm/nvm.sh" &> /dev/null case $- in *i*) bash-it enable completion nvm &> /dev/null; \ - . ${BASH_IT}/completion/available/nvm.completion.bash ;; + . "${BASH_IT}/completion/available/nvm.completion.bash" ;; esac if [[ $(which node) = "${HOME}/.nvm/versions/"* ]]; then __versions @@ -99,8 +99,8 @@ __nvm_unload () { export -f __nvm_unload simple_nodeenv () { - pushd $PWD &> /dev/null - cd ${HOME}/.local/nodeenv + pushd "$PWD" &> /dev/null + cd "${HOME}/.local/nodeenv" nodeenv --prebuilt --node "$@" if [[ $? != 0 ]]; then popd &> /dev/null diff --git a/env/.bashrc b/env/.bashrc index 730e542..80e9da9 100644 --- a/env/.bashrc +++ b/env/.bashrc @@ -1,10 +1,10 @@ -. ${HOME}/.bash_env +. "${HOME}/.bash_env" . /usr/share/bash-completion/completions/git -export BASH_IT=${HOME}/.bash_it +export BASH_IT="${HOME}/.bash_it" export BASH_IT_THEME="nodez" -. ${BASH_IT}/bash_it.sh +. "${BASH_IT}/bash_it.sh" alias nld0='npm ls --depth=0' alias nlgd0='npm ls -g --depth=0' From 31b6995b6d7e93e9502c2739d1ccf62ea28110aa Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 19:31:00 -0500 Subject: [PATCH 17/22] don't add .local/bin to the path multiple times --- env/.bash_env | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/env/.bash_env b/env/.bash_env index 1b6a0a4..3c0a390 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -1,6 +1,8 @@ unset BASH_ENV -export PATH="${HOME}/.local/bin:$PATH" +if [[ :$PATH: != *:"${HOME}/.local/bin":* ]] ; then + export PATH="${HOME}/.local/bin:$PATH" +fi nac () { local txtbld=$(tput bold) From 6f0e8d292ebfd5bb06e9c082f410e92c23bf6486 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 19:31:22 -0500 Subject: [PATCH 18/22] change order of unload --- env/.bash_env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env/.bash_env b/env/.bash_env index 3c0a390..7f1271e 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -17,8 +17,8 @@ nac () { echo "$ERROR: no \"$1\" environment found in ${HOME}/.local/nodeenv" return 1 fi - __nvm_unload __denac + __nvm_unload . "${HOME}/.local/nodeenv/$1/bin/activate" if [[ $? != 0 ]]; then __denac From d0c41a2d3c49a32c30a497ae247518facc6484d5 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 19:31:42 -0500 Subject: [PATCH 19/22] export some nodeenv env vars so they get kicked down from entry --- env/.bash_env | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/env/.bash_env b/env/.bash_env index 7f1271e..86eaf91 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -24,9 +24,15 @@ nac () { __denac return 1 fi - __versions + export -f deactivate_node + export _OLD_NODE_PATH + export _OLD_NODE_VIRTUAL_PATH + export _OLD_NODE_VIRTUAL_PS1 + export _OLD_npm_config_prefix + export _OLD_NPM_CONFIG_PREFIX alias denac='deactivate_node' alias deactivate_node='__denac' + __versions case $- in *i*) __npm_completion ;; esac @@ -127,4 +133,12 @@ export -f __versions if [[ ! -v NODE_VIRTUAL_ENV ]]; then nac default +else + if ! type denac &> /dev/null; then + alias denac='deactivate_node' + alias deactivate_node='__denac' + case $- in + *i*) __npm_completion ;; + esac + fi fi From d6bb268315989935fe77798f4f3c388aedca1369 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Tue, 21 Aug 2018 15:02:42 -0500 Subject: [PATCH 20/22] nodeenv exports need to be in a sourced file to avoid nvm conflict --- Dockerfile | 1 + env/.bash_env | 6 +----- env/.bash_env_nodeenv_exports | 5 +++++ 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 env/.bash_env_nodeenv_exports diff --git a/Dockerfile b/Dockerfile index 1c55c04..1c0e5dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -192,6 +192,7 @@ COPY env/docker-entrypoint.sh \ /usr/local/bin/ COPY --chown=embark:embark \ env/.bash_env \ + env/.bash_env_nodeenv_exports \ env/.bash_env_unset_npm_config \ env/.bashrc \ env/.npmrc \ diff --git a/env/.bash_env b/env/.bash_env index 86eaf91..8a00d72 100644 --- a/env/.bash_env +++ b/env/.bash_env @@ -25,11 +25,7 @@ nac () { return 1 fi export -f deactivate_node - export _OLD_NODE_PATH - export _OLD_NODE_VIRTUAL_PATH - export _OLD_NODE_VIRTUAL_PS1 - export _OLD_npm_config_prefix - export _OLD_NPM_CONFIG_PREFIX + . "${HOME}/.bash_env_nodeenv_exports" alias denac='deactivate_node' alias deactivate_node='__denac' __versions diff --git a/env/.bash_env_nodeenv_exports b/env/.bash_env_nodeenv_exports new file mode 100644 index 0000000..9d75221 --- /dev/null +++ b/env/.bash_env_nodeenv_exports @@ -0,0 +1,5 @@ +export _OLD_NODE_PATH +export _OLD_NODE_VIRTUAL_PATH +export _OLD_NODE_VIRTUAL_PS1 +export _OLD_npm_config_prefix +export _OLD_NPM_CONFIG_PREFIX From c88f29d67c447e3d66ed32139982044a9221290a Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Tue, 21 Aug 2018 21:02:35 -0500 Subject: [PATCH 21/22] more DRY re: env vars --- run.sh | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/run.sh b/run.sh index 8f72bfa..326d662 100755 --- a/run.sh +++ b/run.sh @@ -37,21 +37,22 @@ run_embark () { "${EMBARK_DOCKER_MOUNT_SOURCE}:${EMBARK_DOCKER_MOUNT_TARGET}" ) - if [[ -v LANG ]]; then - run_opts=( "${run_opts[@]}" "-e" "LANG" ) - fi - - if [[ -v LANGUAGE ]]; then - run_opts=( "${run_opts[@]}" "-e" "LANGUAGE" ) - fi - - if [[ -v LC_ALL ]]; then - run_opts=( "${run_opts[@]}" "-e" "LC_ALL" ) - fi - - if [[ -v TERM ]]; then - run_opts=( "${run_opts[@]}" "-e" "TERM" ) - fi + local env_var + for env_var in LANG \ + LANGUAGE \ + LC_ALL \ + TERM; + # do not alter indentation, tabs in lines below + do + local include_var=$(cat <<- ENV_VAR + if [[ -n $env_var && -v $env_var ]]; then + run_opts=( "${run_opts[@]}" "-e" "$env_var" ) + fi + ENV_VAR + ) + eval "$include_var" + done + # do not alter indentation, tabs in lines above if [[ $EMBARK_DOCKER_RUN_RM = true ]]; then run_opts=( "${run_opts[@]}" "--rm" ) From a82122949902ec1d784e4928342c4d55b4622702 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 22 Aug 2018 16:41:50 -0500 Subject: [PATCH 22/22] downgrade geth/swarm (1.8.12 geth alltools includes swarm) --- Dockerfile | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c0e5dd..bac70f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_TAG=stretch ARG EMBARK_VERSION=latest ARG GANACHE_VERSION=6.1.0 -ARG GETH_VERSION=1.8.13-225171a4 +ARG GETH_VERSION=1.8.12-37685930 ARG IPFS_VERSION=0.4.17 ARG MICRO_VERSION=1.4.1 ARG NODE_VERSION=8.11.3 @@ -15,7 +15,6 @@ ARG NODEENV_VERSION=1.3.2 ARG NPM_VERSION=6.4.0 ARG NVM_VERSION=0.33.11 ARG SUEXEC_VERSION=0.2 -ARG SWARM_VERSION=0.3.1-225171a4 # multi-stage builder images # ------------------------------------------------------------------------------ @@ -83,16 +82,6 @@ RUN git clone --branch v${SUEXEC_VERSION} \ && cd su-exec \ && make -# ------------------------------------------------------------------------------ - -FROM builder-base as builder-swarm -ARG SWARM_VERSION -RUN export url="https://gethstore.blob.core.windows.net/builds" \ - && export platform="swarm-linux-amd64" \ - && curl -fsSLO --compressed "${url}/${platform}-${SWARM_VERSION}.tar.gz" \ - && tar -xvzf swarm* \ - && rm swarm*/COPYING - # final image # ------------------------------------------------------------------------------ @@ -154,7 +143,6 @@ ARG GETH_VERSION ARG IPFS_VERSION ARG MICRO_VERSION ARG SUEXEC_VERSION -ARG SWARM_VERSION ENV __CODESET=${__CODESET} \ __LANG=${__LANG} \ __LANGUAGE=${__LANGUAGE} \ @@ -169,8 +157,7 @@ ENV __CODESET=${__CODESET} \ MICRO_VERSION=${MICRO_VERSION} \ NODEENV_VERSION=${NODEENV_VERSION} \ NVM_VERSION=${NVM_VERSION} \ - SUEXEC_VERSION=${SUEXEC_VERSION} \ - SWARM_VERSION=${SWARM_VERSION} + SUEXEC_VERSION=${SUEXEC_VERSION} SHELL ["/bin/sh", "-c"] USER root WORKDIR /dapp @@ -185,7 +172,6 @@ EXPOSE 5001 8000 8080 8500 8545 8546 8555 8556 30301/udp 30303 COPY --from=builder-geth /geth-alltools* /usr/local/bin/ COPY --from=builder-micro /micro*/micro /usr/local/bin/ COPY --from=builder-suexec /su-exec/su-exec /usr/local/bin/ -COPY --from=builder-swarm /swarm* /usr/local/bin/ COPY env/docker-entrypoint.sh \ env/user-entrypoint.sh \ env/install-extras.sh \