-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
79 lines (51 loc) · 1.76 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# --- Base ----
FROM cypress/base:14 AS base
# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app
# --- Builder ----
FROM base AS builder
# Creates a caching layer using both package.json AND package-lock.json
COPY package*.json /usr/src/app/
# Install production only modules to be used in the released image
RUN npm ci --only=production
RUN cp -R node_modules prod_node_modules
# Install all modules for everything else
RUN npm ci
# --- Development ---
FROM base AS dev
ENV PORT 3000
EXPOSE 3000
# Copies over pre-installed dependencies
COPY --from=builder /usr/src/app/node_modules ./node_modules
RUN npx next telemetry disable
# maybe can move the build into the builder step?
# Copies the source code into the working directory in the container
COPY . /usr/src/app
CMD [ "npm", "run", "dev" ]
# --- Release ---
FROM base AS release
ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000
# Copies over pre-installed dependencies for production
COPY --from=builder /usr/src/app/prod_node_modules ./node_modules
# maybe can move the build into the builder step?
# Copies the source code into the working directory in the container
COPY . /usr/src/app
# Builds the nextjs application
RUN npm run build
RUN npx next telemetry disable
# RUN addgroup -g 1001 -S nodejs
# RUN adduser -S nextjs -u 1001
# USER nextjs
CMD [ "npm", "start" ]
# --- Cypress E2E ---
FROM base AS cypress
# Cypress caches the binary in ~/root
COPY --from=builder /root/.cache/ /root/.cache/
# Copies over pre-installed dependencies
COPY --from=builder /usr/src/app/node_modules ./node_modules
# maybe can move the build into the builder step?
# Copies the source code into the working directory in the container
COPY . /usr/src/app
CMD [ "npm", "run", "test:cypress" ]