forked from iloveluce/sequence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ui
60 lines (50 loc) · 1.84 KB
/
Dockerfile.ui
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
# Based off of https://nextjs.org/docs/deployment#docker-image
# Install dependencies for all subprojects
FROM node:alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat
# Install lerna
RUN yarn global add lerna
# Root package.json for all modules
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY packages/common ./packages/common
COPY packages/ui ./packages/ui
COPY lerna.json tsconfig.json ./
RUN yarn run bootstrap
# Install UI dependencies
FROM node:alpine AS ui-builder
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY --from=base /app .
WORKDIR /app/packages/ui
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
# Build Common
FROM node:alpine AS common-builder
WORKDIR /app
COPY --from=base /app .
WORKDIR /app/packages/common
ENV NEXT_PUBLIC_API_URL=http://0.0.0.0:3000/graphql
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
# Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app/packages/ui
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
COPY . .
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=ui-builder /app/packages/ui/.env ./.env
COPY --from=ui-builder /app/packages/ui/next.config.js ./
COPY --from=ui-builder /app/packages/ui/public ./public
COPY --from=ui-builder --chown=nextjs:nodejs /app/packages/ui/.next ./.next
COPY --from=ui-builder /app/packages/ui/node_modules ./node_modules
COPY --from=ui-builder /app/packages/ui/package.json ./package.json
USER nextjs
EXPOSE 8000
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 8000
CMD ["yarn", "start"]