Skip to content

Instantly share code, notes, and snippets.

@pi0
Last active August 29, 2018 21:04
Show Gist options
  • Save pi0/3363dd8048dde009faeeb6fa6ce5d23f to your computer and use it in GitHub Desktop.
Save pi0/3363dd8048dde009faeeb6fa6ce5d23f to your computer and use it in GitHub Desktop.
Multi Stage Docker Builds for Node.js
.yarn_mirror
yarn-offline-mirror "./.yarn_mirror"
yarn-offline-mirror-pruning "true"
#!/bin/bash
set -xe
IMG=...
# yarn build
docker build -t $IMG --network none .
docker push $IMG
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