Skip to content

Commit

Permalink
Issue #55: Update Dockerfile to use multi-stage build
Browse files Browse the repository at this point in the history
The Dockerfile now has two build stages, one for development with dependecies installed while
the production stage only has the application itself, making the production image much smaller.
  • Loading branch information
CarlosRodrigo authored and rodrigoperazzo committed Mar 7, 2019
1 parent 1817317 commit a8fc5c1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM node:lts-alpine

# install simple http server for serving static content
RUN npm install -g http-server
FROM node:lts-alpine as dev

# make the 'app' folder the current working directory
WORKDIR /app
Expand All @@ -19,4 +16,10 @@ COPY . .
RUN npm run build

EXPOSE 8080
CMD [ "http-server", "dist" ]
CMD [ "npm", "run", "dev" ]

# production stage
FROM nginx:stable-alpine as prod
COPY --from=dev /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit a8fc5c1

Please sign in to comment.