Last active
August 29, 2018 21:04
-
-
Save pi0/3363dd8048dde009faeeb6fa6ce5d23f to your computer and use it in GitHub Desktop.
Multi Stage Docker Builds for Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.yarn_mirror |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn-offline-mirror "./.yarn_mirror" | |
yarn-offline-mirror-pruning "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xe | |
IMG=... | |
# yarn build | |
docker build -t $IMG --network none . | |
docker push $IMG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM banian/node | |
ENV NODE_ENV=production | |
ADD . /usr/src/app | |
RUN yarn install --prod --offline && \ | |
rm -rf .yarn_mirror && \ | |
mv node_modules /tmp | |
FROM banian/node | |
ENV NODE_ENV=production | |
COPY --from=0 /tmp/node_modules /usr/src/app/node_modules | |
COPY --from=0 /usr/src/app /usr/src/app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment