-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
46 lines (32 loc) · 1.02 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
FROM node:14-buster-slim AS base
WORKDIR /build
# Prepare for installing dependencies
# Utilise Docker cache to save re-installing dependencies if unchanged
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile
FROM base as build
# Copy the rest files
COPY . .
# Build application
RUN yarn build
FROM base as prod-deps
# Prune unused dependencies
RUN npm prune --production
FROM node:14-buster-slim AS production
ENV NODE_ENV production
WORKDIR /app
RUN npm install -g serve
# Copy only necessary file for running app
COPY --from=prod-deps /build/package.json ./package.json
COPY --from=prod-deps /build/node_modules ./node_modules
COPY --from=build /build/build ./build
COPY --from=build /build/public ./public
COPY --from=build /build/tailwind.config.js ./tailwind.config.js
COPY --from=build /build/postcss.config.js ./postcss.config.js
# Expose listening port
EXPOSE 3000
# Run container as non-root (unprivileged) user
# The node user is provided in the Node.js Alpine base image
USER node
# Staring script
CMD serve -s build