Skip to content

Instantly share code, notes, and snippets.

@jeckel jeckel/.dockerignore
Last active Sep 4, 2018

Embed
What would you like to do?
Production ready nodejs Dockerfile sample
# 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
FROM node:9-alpine AS builder
LABEL maintainer="Julien MERCIER <devci@j3ck3l.me>"
# 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
You can’t perform that action at this time.