forked from mikesparr/typescript-postgres-auth-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (25 loc) · 740 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
# Using multi-stage build (supported Docker 17 and later)
# Original image 225MB and now 71MB
# ------ Stage 1 (build) --------
FROM node:alpine AS assets
# Create app directory
WORKDIR /usr/src/app
# Copy source code to image
COPY . .
# Add compile dependencies (since Alpine doesn't have python to compile libs)
RUN apk update && \
apk --no-cache --virtual build-dependencies add \
python \
make \
g++ \
&& npm install \
&& apk del build-dependencies
# Create ./dist folder for deploy later
RUN npm run build
# ------ Stage 2 (release) ------
FROM node:10-alpine AS release
WORKDIR /usr/src/app
COPY --from=assets /usr/src/app/dist ./dist
# Expose port 3000 and start app
EXPOSE 3000
CMD [ "npm", "start" ]