forked from clintonwoo/hackernews-react-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (28 loc) · 879 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# DEV BUILD STEP
FROM node:10.15.3-alpine as devBuild
WORKDIR /usr/src/app
# Log the settings for NPM and Environment variables
RUN npm config ls
RUN env
# Copy the source code and build
COPY . .
RUN npm install
RUN npm run build
# PROD BUILD STEP
# Using latest LTS release of Node
FROM node:10.15.3-alpine
# Create an app directory on the container
WORKDIR /usr/src/app
ENV NODE_ENV=production
# Project copy build, install only prod dependencies
COPY --from=devBuild /usr/src/app/dist ./dist
COPY package.json package-lock.json README.md ./
RUN npm install --only=prod
# Install curl to do healthchecks
RUN apk add curl --no-cache
# Expose the container port to the OS
# docker run takes -p argument to forward this port to network
EXPOSE 3000
# Start the application
CMD npm run start:production
HEALTHCHECK CMD curl --silent --fail http://localhost:3000/ || exit 1