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 __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
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 EMBARK_VERSION=latest
ARG GANACHE_VERSION=6.1.0
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
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
@ -26,7 +27,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 \
@ -87,6 +89,7 @@ FROM builder-base
LABEL maintainer="Andre Medeiros <andre@status.im>"
ARG BASHIT_VERSION
ARG EMBARK_VERSION
ARG GANACHE_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/
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 +147,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} \
@ -173,8 +178,8 @@ 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_nodeenv_exports \
env/.bash_env_unset_npm_config \
env/.bashrc \
env/.npmrc \
/home/embark/

47
env/.bash_env vendored
View File

@ -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)
@ -15,16 +17,18 @@ nac () {
echo "$ERROR: no \"$1\" environment found in ${HOME}/.local/nodeenv"
return 1
fi
__nvm_unload
__denac
. ${HOME}/.local/nodeenv/$1/bin/activate
__nvm_unload
. "${HOME}/.local/nodeenv/$1/bin/activate"
if [[ $? != 0 ]]; then
__denac
return 1
fi
__versions_export
export -f deactivate_node
. "${HOME}/.bash_env_nodeenv_exports"
alias denac='deactivate_node'
alias deactivate_node='__denac'
__versions
case $- in
*i*) __npm_completion ;;
esac
@ -46,9 +50,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 +67,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 +75,15 @@ nvm_load () {
export -f nvm_load
__nvm_load () {
__nvm_unload
__denac
. ${HOME}/.bash_env_nvm_load
. ${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_export
__versions
case $- in
*i*) __npm_completion ;;
esac
@ -96,14 +98,13 @@ __nvm_unload () {
if type nvm &> /dev/null; then
nvm unload
fi
unset NODE_VERSION
unset NPM_VERSION
__versions
}
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
@ -114,7 +115,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,8 +125,16 @@ __versions_export () {
unset NPM_VERSION
fi
}
export -f __versions_export
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

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

View File

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

View File

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

70
run.sh
View File

@ -35,10 +35,25 @@ run_embark () {
"30303:30303"
"-v"
"${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
run_opts=( "${run_opts[@]}" "--rm" )
fi
@ -61,23 +76,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
@ -85,18 +99,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=()
@ -162,21 +165,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