-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
55 lines (45 loc) · 1.35 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
###########################################################
# Build container
###########################################################
FROM node:16 AS builder
# Prepare arguments
ARG service
ARG BUGSNAG_API_KEY
ARG APP_ENV=production
ARG APP_VERSION=docker-build
ARG CLIENT_URL=https://ud.me
# Use development environment during build to allow development dependencies
# to be installed which includes build tools
ENV NODE_ENV development
ENV APP_ENV $APP_ENV
ENV APP_VERSION $APP_VERSION
ENV BUGSNAG_API_KEY $BUGSNAG_API_KEY
ENV CLIENT_URL $CLIENT_URL
ENV NEXT_TELEMETRY_DISABLED 1
ENV YARN_IGNORE_NODE 1
# Copy project files
WORKDIR /app
COPY . .
# Build project dependencies including dev dependencies
RUN yarn install
RUN yarn build
RUN NODE_ENV=production yarn workspace server build:next
## Remove extra files to reduce image size
RUN rm -rf node_modules \
&& NODE_ENV=production yarn install
RUN rm -rf .yarn/cache
###########################################################
# Runtime container
###########################################################
FROM node:16-alpine
# Runtime environment variables
ARG service
ENV NEXT_TELEMETRY_DISABLED 1
ENV YARN_IGNORE_NODE 1
# Runtime dependencies
RUN yarn set version 3.2.0
# Copy project files
WORKDIR /app
COPY --from=builder /app .
# Server start command
CMD ["yarn", "workspace", "server", "run", "start"]