Merge pull request #6 from embark-framework/pre-3.1.10-tidyup

Pre 3.1.10 tidying up
This commit is contained in:
Iuri Matias 2018-08-23 14:39:43 -04:00 committed by GitHub
commit 9b91fde09c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 90 additions and 75 deletions

View File

@ -2,16 +2,17 @@ ARG __CODESET=UTF-8
ARG __LANG=en_US.${__CODESET} ARG __LANG=en_US.${__CODESET}
ARG __LANGUAGE=en_US:en ARG __LANGUAGE=en_US:en
ARG __LC_ALL=en_US.${__CODESET} ARG __LC_ALL=en_US.${__CODESET}
ARG BASHIT_VERSION=10-aug-2018
ARG BUILDER_BASE_IMAGE=buildpack-deps ARG BUILDER_BASE_IMAGE=buildpack-deps
ARG BUILDER_BASE_TAG=stretch ARG BUILDER_BASE_TAG=stretch
ARG EMBARK_VERSION=3.1.5 ARG EMBARK_VERSION=latest
ARG GANACHE_VERSION=6.1.4 ARG GANACHE_VERSION=6.1.0
ARG GETH_VERSION=1.8.11-dea1ce05 ARG GETH_VERSION=1.8.12-37685930
ARG IPFS_VERSION=0.4.15 ARG IPFS_VERSION=0.4.17
ARG MICRO_VERSION=1.4.0 ARG MICRO_VERSION=1.4.1
ARG NODE_VERSION=8.11.3 ARG NODE_VERSION=8.11.3
ARG NODEENV_VERSION=1.3.2 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 NVM_VERSION=0.33.11
ARG SUEXEC_VERSION=0.2 ARG SUEXEC_VERSION=0.2
@ -26,7 +27,8 @@ ARG __LC_ALL
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
RUN export DEBIAN_FRONTEND=noninteractive \ RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \ && apt-get update \
&& apt-get install -y locales \ && apt-get install -y less \
locales \
&& sed -i \ && sed -i \
-e "s/# ${__LANG} ${__CODESET}/${__LANG} ${__CODESET}/" \ -e "s/# ${__LANG} ${__CODESET}/${__LANG} ${__CODESET}/" \
/etc/locale.gen \ /etc/locale.gen \
@ -87,6 +89,7 @@ FROM builder-base
LABEL maintainer="Andre Medeiros <andre@status.im>" LABEL maintainer="Andre Medeiros <andre@status.im>"
ARG BASHIT_VERSION
ARG EMBARK_VERSION ARG EMBARK_VERSION
ARG GANACHE_VERSION ARG GANACHE_VERSION
ARG NODE_VERSION ARG NODE_VERSION
@ -105,8 +108,9 @@ RUN adduser --disabled-password --shell /bin/bash --gecos "" embark \
COPY --from=builder-ipfs /go-ipfs/ipfs /usr/local/bin/ COPY --from=builder-ipfs /go-ipfs/ipfs /usr/local/bin/
USER embark USER embark
WORKDIR /home/embark WORKDIR /home/embark
RUN git clone --depth 1 \ RUN git clone --branch ${BASHIT_VERSION} \
https://github.com/Bash-it/bash-it.git \ --depth 1 \
https://github.com/michaelsbradleyjr/bash-it.git \
.bash_it 2> /dev/null \ .bash_it 2> /dev/null \
&& mkdir -p .bash_it/custom/themes/nodez \ && mkdir -p .bash_it/custom/themes/nodez \
&& git clone --branch v${NVM_VERSION} \ && git clone --branch v${NVM_VERSION} \
@ -143,6 +147,7 @@ ENV __CODESET=${__CODESET} \
__LANG=${__LANG} \ __LANG=${__LANG} \
__LANGUAGE=${__LANGUAGE} \ __LANGUAGE=${__LANGUAGE} \
__LC_ALL=${__LC_ALL} \ __LC_ALL=${__LC_ALL} \
BASHIT_VERSION=${BASHIT_VERSION} \
BUILDER_BASE_IMAGE=${BUILDER_BASE_IMAGE} \ BUILDER_BASE_IMAGE=${BUILDER_BASE_IMAGE} \
BUILDER_BASE_TAG=${BUILDER_BASE_TAG} \ BUILDER_BASE_TAG=${BUILDER_BASE_TAG} \
EMBARK_VERSION=${EMBARK_VERSION} \ EMBARK_VERSION=${EMBARK_VERSION} \
@ -173,8 +178,8 @@ COPY env/docker-entrypoint.sh \
/usr/local/bin/ /usr/local/bin/
COPY --chown=embark:embark \ COPY --chown=embark:embark \
env/.bash_env \ env/.bash_env \
env/.bash_env_denac \ env/.bash_env_nodeenv_exports \
env/.bash_env_nvm_load \ env/.bash_env_unset_npm_config \
env/.bashrc \ env/.bashrc \
env/.npmrc \ env/.npmrc \
/home/embark/ /home/embark/

47
env/.bash_env vendored
View File

@ -1,6 +1,8 @@
unset BASH_ENV unset BASH_ENV
export PATH=${HOME}/.local/bin:$PATH if [[ :$PATH: != *:"${HOME}/.local/bin":* ]] ; then
export PATH="${HOME}/.local/bin:$PATH"
fi
nac () { nac () {
local txtbld=$(tput bold) local txtbld=$(tput bold)
@ -15,16 +17,18 @@ nac () {
echo "$ERROR: no \"$1\" environment found in ${HOME}/.local/nodeenv" echo "$ERROR: no \"$1\" environment found in ${HOME}/.local/nodeenv"
return 1 return 1
fi fi
__nvm_unload
__denac __denac
. ${HOME}/.local/nodeenv/$1/bin/activate __nvm_unload
. "${HOME}/.local/nodeenv/$1/bin/activate"
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
__denac __denac
return 1 return 1
fi fi
__versions_export export -f deactivate_node
. "${HOME}/.bash_env_nodeenv_exports"
alias denac='deactivate_node' alias denac='deactivate_node'
alias deactivate_node='__denac' alias deactivate_node='__denac'
__versions
case $- in case $- in
*i*) __npm_completion ;; *i*) __npm_completion ;;
esac esac
@ -46,9 +50,8 @@ __denac () {
if type deactivate_node &> /dev/null; then if type deactivate_node &> /dev/null; then
deactivate_node deactivate_node
fi fi
. ${HOME}/.bash_env_denac . "${HOME}/.bash_env_unset_npm_config"
unset NODE_VERSION __versions
unset NPM_VERSION
} }
export -f __denac export -f __denac
@ -64,7 +67,7 @@ nvm_load () {
__nvm_mask () { __nvm_mask () {
case "$*" in case "$*" in
unload*) __nvm_unload ;; unload*) __nvm_unload ;;
*) unalias nvm; nvm "$@"; alias nvm='__nvm_mask'; __versions_export ;; *) unalias nvm; nvm "$@"; alias nvm='__nvm_mask'; __versions ;;
esac esac
} }
export -f __nvm_mask export -f __nvm_mask
@ -72,16 +75,15 @@ nvm_load () {
export -f nvm_load export -f nvm_load
__nvm_load () { __nvm_load () {
__nvm_unload
__denac __denac
. ${HOME}/.bash_env_nvm_load __nvm_unload
. ${HOME}/.nvm/nvm.sh &> /dev/null . "${HOME}/.nvm/nvm.sh" &> /dev/null
case $- in case $- in
*i*) bash-it enable completion nvm &> /dev/null; \ *i*) bash-it enable completion nvm &> /dev/null; \
. ${BASH_IT}/completion/available/nvm.completion.bash ;; . "${BASH_IT}/completion/available/nvm.completion.bash" ;;
esac esac
if [[ $(which node) = "${HOME}/.nvm/versions/"* ]]; then if [[ $(which node) = "${HOME}/.nvm/versions/"* ]]; then
__versions_export __versions
case $- in case $- in
*i*) __npm_completion ;; *i*) __npm_completion ;;
esac esac
@ -96,14 +98,13 @@ __nvm_unload () {
if type nvm &> /dev/null; then if type nvm &> /dev/null; then
nvm unload nvm unload
fi fi
unset NODE_VERSION __versions
unset NPM_VERSION
} }
export -f __nvm_unload export -f __nvm_unload
simple_nodeenv () { simple_nodeenv () {
pushd $PWD &> /dev/null pushd "$PWD" &> /dev/null
cd ${HOME}/.local/nodeenv cd "${HOME}/.local/nodeenv"
nodeenv --prebuilt --node "$@" nodeenv --prebuilt --node "$@"
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
popd &> /dev/null popd &> /dev/null
@ -114,7 +115,7 @@ simple_nodeenv () {
} }
export -f simple_nodeenv export -f simple_nodeenv
__versions_export () { __versions () {
if type node &> /dev/null; then if type node &> /dev/null; then
local node_version=$(node --version) local node_version=$(node --version)
export NODE_VERSION=${node_version##v} export NODE_VERSION=${node_version##v}
@ -124,8 +125,16 @@ __versions_export () {
unset NPM_VERSION unset NPM_VERSION
fi fi
} }
export -f __versions_export export -f __versions
if [[ ! -v NODE_VIRTUAL_ENV ]]; then if [[ ! -v NODE_VIRTUAL_ENV ]]; then
nac default 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 fi

5
env/.bash_env_nodeenv_exports vendored Normal file
View File

@ -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

View File

@ -1,2 +0,0 @@
unset npm_config_prefix
unset NPM_CONFIG_PREFIX

9
env/.bashrc vendored
View File

@ -1,7 +1,10 @@
. ${HOME}/.bash_env . "${HOME}/.bash_env"
. /usr/share/bash-completion/completions/git . /usr/share/bash-completion/completions/git
export BASH_IT=${HOME}/.bash_it export BASH_IT="${HOME}/.bash_it"
export BASH_IT_THEME="nodez" 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'

View File

@ -2,7 +2,6 @@
apt-get update apt-get update
apt-get install -y \ apt-get install -y \
less \
lsof \ lsof \
net-tools \ net-tools \
parallel \ parallel \

View File

@ -34,6 +34,10 @@ __nodez_ne() {
__nodez_nv() { __nodez_nv() {
if [[ -v NODE_VERSION ]]; then if [[ -v NODE_VERSION ]]; then
local nv="${__nodez_char_node}${NODE_VERSION}" 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}]" nv+="${__nodez_char_npm}${NPM_VERSION}]"
echo "$nv" echo "$nv"
fi fi

70
run.sh
View File

@ -35,10 +35,25 @@ run_embark () {
"30303:30303" "30303:30303"
"-v" "-v"
"${EMBARK_DOCKER_MOUNT_SOURCE}:${EMBARK_DOCKER_MOUNT_TARGET}" "${EMBARK_DOCKER_MOUNT_SOURCE}:${EMBARK_DOCKER_MOUNT_TARGET}"
"-e"
"TERM"
) )
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 if [[ $EMBARK_DOCKER_RUN_RM = true ]]; then
run_opts=( "${run_opts[@]}" "--rm" ) run_opts=( "${run_opts[@]}" "--rm" )
fi fi
@ -61,23 +76,22 @@ run_embark () {
esac esac
set +e set +e
cleanup () {
local retval=$?
unset check_bash_version
unset check_docker
unset cleanup
eval "$oldopts"
return $retval
}
check_bash_version () { check_bash_version () {
if [[ $BASH_VERSINFO -lt 4 ]]; then if [[ $BASH_VERSINFO -lt 4 ]]; then
echo "$ERROR: this script requires Bash version >= 4.0" echo "$ERROR: this script requires Bash version >= 4.0"
return 1 return 1
fi fi
} }
check_bash_version check_bash_version || cleanup || return
if [[ $? = 1 ]]; then
unset check_bash_version
eval "$oldopts"
if [[ "$0" != "$BASH_SOURCE" ]]; then
return 1
else
exit 1
fi
fi
check_docker () { check_docker () {
if ! type docker &> /dev/null; then if ! type docker &> /dev/null; then
@ -85,18 +99,7 @@ run_embark () {
return 127 return 127
fi fi
} }
check_docker check_docker || cleanup || return
if [[ $? = 127 ]]; then
unset check_bash_version
unset check_docker
eval "$oldopts"
if [[ "$0" != "$BASH_SOURCE" ]]; then
return 127
else
exit 127
fi
fi
local had_run_opts=false local had_run_opts=false
local -a _run_opts=() local -a _run_opts=()
@ -162,21 +165,10 @@ run_embark () {
docker run \ docker run \
"${run_opts[@]}" \ "${run_opts[@]}" \
"${EMBARK_DOCKER_IMAGE}:${EMBARK_DOCKER_TAG}" \ "${EMBARK_DOCKER_IMAGE}:${EMBARK_DOCKER_TAG}" \
"${cmd[@]}" "${cmd[@]}" \
|| cleanup || return
local docker_exit_status=$? cleanup
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
} }
export -f run_embark export -f run_embark