Skip to content

Commit

Permalink
closes #3 multi-stage dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
csimi committed Apr 4, 2019
1 parent bb91b54 commit bdedbdf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
25 changes: 17 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
FROM node:dubnium-alpine
FROM node:dubnium-alpine as builder

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Binary dependency
RUN apk --no-cache add openssl

# Install app dependencies
COPY package.json npm-shrinkwrap.json /usr/src/app/
RUN npm install --quiet

# Bundle app source
COPY . /usr/src/app

# Build front-end
RUN npm run build

# Run app
EXPOSE 3000
CMD ["npm", "run", "dev"]

FROM node:dubnium-alpine

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN apk --no-cache add openssl

COPY package.json npm-shrinkwrap.json /usr/src/app/
RUN npm install --quiet --only=production

COPY . /usr/src/app
COPY --from=builder /usr/src/app/dist ./dist

EXPOSE 3000
CMD ["npm", "start"]
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ services:
node:
build:
context: .
entrypoint:
- npm
- run
- dev
target: builder
depends_on:
- redis
ports:
Expand Down
20 changes: 6 additions & 14 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"body-parser": "^1.18.3",
"cross-env": "^5.2.0",
"env-var": "^3.5.0",
"express": "^4.16.4",
"express-async-router": "^0.1.15",
Expand All @@ -36,7 +37,6 @@
"babel-loader": "^8.0.5",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"cookie": "^0.3.1",
"cross-env": "^5.2.0",
"css-loader": "^2.1.1",
"date-fns": "^1.30.1",
"eslint": "^5.16.0",
Expand Down

0 comments on commit bdedbdf

Please sign in to comment.