Chapter 11: add Dockerfile-run

This commit is contained in:
Beth Griggs 2020-11-15 03:58:59 +00:00
parent c7615d1daf
commit c5506a3f0c
No known key found for this signature in database
GPG Key ID: D7062848A1AB005C

View File

@ -0,0 +1,31 @@
FROM node:14
WORKDIR "/app"
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& echo 'Finished installing dependencies'
COPY package*.json ./
RUN npm install --production
FROM node:14-slim
WORKDIR "/app"
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& echo 'Finished installing dependencies'
COPY --from=0 /app/node_modules /app/node_modules
COPY . /app
ENV NODE_ENV production
ENV PORT 3000
USER node
EXPOSE 3000
CMD ["npm", "start"]