Last active
September 4, 2018 06:34
-
-
Save jeckel/ba094202f1c6636a1568cd9156e155c0 to your computer and use it in GitHub Desktop.
Production ready nodejs Dockerfile sample
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
# Ignore all .files except .babelrc | |
.* | |
!.babelrc | |
# Ignore build directories and dependencies | |
# everything that will be re-generated by the install/build steps | |
lib | |
dist | |
node_modules | |
# Ignore dev configuration files | |
docker-compose.yml | |
Dockerfile | |
Makefile | |
nodemon.json | |
# Remove documentation | |
*.md | |
# Ignore tests files | |
src/**/*.test.js | |
test | |
jest.config.json |
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 node:9-alpine AS builder | |
LABEL maintainer="Julien MERCIER <[email protected]>" | |
# Build project | |
WORKDIR /home/node/app | |
COPY . . | |
# Build whatever you have to build (babel, grunt, webpack, etc.) | |
RUN npm install && \ | |
npm run build | |
# Make the run container | |
# | |
FROM node:9-alpine | |
ENV NODE_ENV=production | |
WORKDIR /home/node/app | |
# Install deps for production only | |
COPY ./package* ./ | |
RUN npm install && \ | |
npm cache clean --force | |
# Copy build source from builder stage | |
COPY --from=builder /home/node/app/dist ./dist | |
CMD npm start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment