Break up the build process in 2.

This will produce an extra layer but will improve on build time because
we'll be updating Embark more frequently than the surrounding tools
(geth and IPFS.)

Also, doing this negates the need to `sudo - embark` a bunch of commands
we previously had to.

Additionally, create and use a workdir.
This commit is contained in:
Andre Medeiros 2018-07-09 12:13:52 -04:00
parent 8d21abc9d6
commit 067866af99

View File

@ -2,7 +2,7 @@ FROM node:8.11.3-stretch
MAINTAINER Andre Medeiros <andre@status.im> MAINTAINER Andre Medeiros <andre@status.im>
ENV EMBARK_VERSION=3.1.4 \ ENV EMBARK_VERSION=3.1.5 \
GANACHE_VERSION=6.1.4 \ GANACHE_VERSION=6.1.4 \
GETH_VERSION=1.8.11-dea1ce05 \ GETH_VERSION=1.8.11-dea1ce05 \
IPFS_VERSION=0.4.15 IPFS_VERSION=0.4.15
@ -34,9 +34,13 @@ RUN adduser --disabled-password --shell /bin/bash --gecos "" embark \
&& tar -xvzf "go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" \ && tar -xvzf "go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" \
&& cp go-ipfs/ipfs /usr/local/bin/ipfs \ && cp go-ipfs/ipfs /usr/local/bin/ipfs \
&& rm -rf go-ipfs "go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" \ && rm -rf go-ipfs "go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" \
# Setup ~embark && mkdir /dapp \
&& su - embark -c "mkdir /home/embark/.npm-packages" \ && chown embark:embark /dapp
&& su - embark -c "echo prefix=/home/embark/.npm-packages > /home/embark/.npmrc" \
USER embark
RUN mkdir /home/embark/.npm-packages \
&& echo prefix=/home/embark/.npm-packages > /home/embark/.npmrc \
&& for directive in \ && for directive in \
"export NPM_PACKAGES=\$HOME/.npm-packages" \ "export NPM_PACKAGES=\$HOME/.npm-packages" \
"export NODE_PATH=\$NPM_PACKAGES/lib/node_modules:\$NODE_PATH" \ "export NODE_PATH=\$NPM_PACKAGES/lib/node_modules:\$NODE_PATH" \
@ -45,12 +49,16 @@ RUN adduser --disabled-password --shell /bin/bash --gecos "" embark \
echo ${directive} >> /home/embark/.profile \ echo ${directive} >> /home/embark/.profile \
&& echo ${directive} >> /home/embark/.bashrc; \ && echo ${directive} >> /home/embark/.bashrc; \
done \ done \
# Ensure we source the updated bashrc
&& . ~/.bashrc \
# Install embark and the simulator # Install embark and the simulator
&& su - embark -c "npm install -g embark@${EMBARK_VERSION} ganache-cli@${GANACHE_VERSION}" \ && npm install -g "embark@${EMBARK_VERSION}" "ganache-cli@${GANACHE_VERSION}" \
# Initialize IPFS
&& ipfs init \
# Cleanup build stuff # Cleanup build stuff
&& echo "Done" && echo "Done"
USER embark WORKDIR /dapp
CMD ["embark"] CMD ["embark"]