-
Notifications
You must be signed in to change notification settings - Fork 356
/
Dockerfile.frontend
31 lines (23 loc) · 755 Bytes
/
Dockerfile.frontend
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
FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat git
WORKDIR /app
COPY frontend/package.json frontend/yarn.lock ./frontend/
RUN cd frontend && yarn install --frozen-lockfile
FROM node:16-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
# Copy everything
COPY . .
COPY --from=deps /app/frontend/node_modules ./frontend/node_modules
RUN cd frontend && yarn build && yarn install --production --ignore-scripts --prefer-offline
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
COPY --from=builder --chown=nextjs:nodejs /app/ .
WORKDIR /app/frontend
USER nextjs
EXPOSE 3000
CMD ["yarn", "start"]