-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecure.Dockerfile
executable file
·50 lines (47 loc) · 1.25 KB
/
secure.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
38
39
40
41
42
43
44
45
46
47
48
49
50
# docker run -it node:8.12-alpine /bin/bash
# ---- Base Node ----
FROM node:10.16-alpine AS base
# Preparing
RUN mkdir -p /var/app && chown -R node /var/app
# Set working directory
WORKDIR /var/app
# Copy project file
COPY packages/secure-app/package.json .
COPY packages/secure-app/yarn.lock .
COPY packages/secure-app/public .
#
# ---- Dependencies ----
FROM base AS dependencies
RUN apk add --update python build-base
# install node packages
RUN yarn install --production --no-progress
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN yarn install --no-progress
# Run in production mode
ENV NODE_ENV=production
#
# ---- Test & Build ----
# run linters, setup and tests
FROM dependencies AS build
COPY . .
# Setup environment variables
ARG API_URI
ARG APP_URI
ENV NODE_ENV=production
RUN yarn secure:build
#
# ---- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /var/app/node_modules ./node_modules
COPY --from=build /var/app/.next ./.next
COPY ./server.js ./server.js
COPY ./next.config.js ./next.config.js
COPY ./public ./public
# Setup environment variables
ENV NODE_ENV=production
# expose port and define CMD
EXPOSE 3000
CMD yarn prod