Merge pull request #1863 from PeterDaveHello/ImproveDockerfile
Improve Dockerfile
commit
96ebed37c7
|
@ -19,12 +19,13 @@ before_install:
|
|||
- curl --version
|
||||
- wget --version
|
||||
install:
|
||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install node && npm install && npm prune && npm ls urchin doctoc eclint; fi
|
||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install node && npm install && npm prune && npm ls urchin doctoc eclint dockerfile_lint; fi
|
||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||
script:
|
||||
- if [ -n "${MAKE_RELEASE-}" ]; then export GIT_EDITOR="sed -i '1 s/^/99.99.99 make release test/'" && git fetch --unshallow --tags && echo proceed | make TAG=99.99.99 release ; fi
|
||||
- if [ -n "${DOCTOCCHECK-}" ]; then cp README.md README.md.orig && npm run doctoc && diff -q README.md README.md.orig ; fi
|
||||
- if [ -n "${ECLINT-}" ]; then npm run eclint ; fi
|
||||
- if [ -n "${DOCKERFILE_LINT-}" ]; then npm run dockerfile_lint ; fi
|
||||
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh ; fi
|
||||
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash install.sh bash_completion nvm-exec ; fi
|
||||
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then if [ "${TEST_SUITE}" = 'installation_iojs' ]; then travis_retry make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; else make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL; fi; fi
|
||||
|
@ -42,6 +43,7 @@ env:
|
|||
- DOCTOCCHECK=true
|
||||
- SHELLCHECK=true
|
||||
- ECLINT=true
|
||||
- DOCKERFILE_LINT=true
|
||||
- SHELL=bash TEST_SUITE=install_script
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
|
|
11
Dockerfile
11
Dockerfile
|
@ -13,6 +13,9 @@ LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
|
|||
LABEL name="nvm-dev-env"
|
||||
LABEL version="latest"
|
||||
|
||||
# Set the SHELL to bash with pipefail option
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Prevent dialog during apt install
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
|
@ -85,6 +88,10 @@ RUN wget --version
|
|||
# Add user "nvm" as non-root user
|
||||
RUN useradd -ms /bin/bash nvm
|
||||
|
||||
# Copy and set permission for nvm directory
|
||||
COPY . /home/nvm/.nvm/
|
||||
RUN chown nvm:nvm -R "home/nvm/.nvm"
|
||||
|
||||
# Set sudoer for "nvm"
|
||||
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
||||
|
||||
|
@ -92,8 +99,6 @@ RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
|||
USER nvm
|
||||
|
||||
# nvm
|
||||
COPY . /home/nvm/.nvm/
|
||||
RUN sudo chown nvm:nvm -R "$HOME/.nvm"
|
||||
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$HOME/.bashrc"
|
||||
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$HOME/.bashrc"
|
||||
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$HOME/.bashrc"
|
||||
|
@ -101,7 +106,7 @@ RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # Th
|
|||
# nodejs and tools
|
||||
RUN bash -c 'source $HOME/.nvm/nvm.sh && \
|
||||
nvm install node && \
|
||||
npm install -g doctoc urchin && \
|
||||
npm install -g doctoc urchin eclint dockerfile_lint && \
|
||||
npm install --prefix "$HOME/.nvm/"'
|
||||
|
||||
# Set WORKDIR to nvm directory
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
"test/installation/iojs": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_iojs test-$shell",
|
||||
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell",
|
||||
"doctoc": "doctoc --title='## Table of Contents' --github README.md",
|
||||
"eclint": "eclint check $(git ls-tree --name-only HEAD | xargs)"
|
||||
"eclint": "eclint check $(git ls-tree --name-only HEAD | xargs)",
|
||||
"dockerfile_lint": "dockerfile_lint"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -35,6 +36,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/creationix/nvm",
|
||||
"devDependencies": {
|
||||
"dockerfile_lint": "^0.3.2",
|
||||
"eclint": "^2.6.0",
|
||||
"replace": "^0.3.0",
|
||||
"semver": "^5.0.1",
|
||||
|
|
Loading…
Reference in New Issue