-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathDockerfile
78 lines (64 loc) · 2.18 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
FROM node:18-alpine AS base
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
# Install build-essential for native addons
RUN apk update && apk add --no-cache python3 make g++ && ln -sf /usr/bin/python3 /usr/bin/python
RUN npm install -g node-gyp sharp
RUN yarn install
# Build the project
COPY --from=builder /app/out/full/ .
# Declare arguments
ARG DATABASE_URL
ARG SUPABASE_URL
ARG SUPABASE_SERVICE_ROLE
ARG EMAIL_KEY
ARG EMAIL_PASS
ARG CRYPT_SECRET
ARG RESEND_KEY
ARG RESEND_WEBHOOK_SECRET
ARG OWNER_EMAIL
ARG NEXT_PUBLIC_MIXPANEL_KEY
ARG CRON_SECRET
# Convert build-time variables to environment variables
ENV DATABASE_URL=$DATABASE_URL \
SUPABASE_URL=$SUPABASE_URL \
SUPABASE_SERVICE_ROLE=$SUPABASE_SERVICE_ROLE \
EMAIL_KEY=$EMAIL_KEY \
EMAIL_PASS=$EMAIL_PASS \
CRYPT_SECRET=$CRYPT_SECRET \
RESEND_KEY=$RESEND_KEY \
RESEND_WEBHOOK_SECRET=$RESEND_WEBHOOK_SECRET \
OWNER_EMAIL=$OWNER_EMAIL \
NEXT_PUBLIC_MIXPANEL_KEY=$NEXT_PUBLIC_MIXPANEL_KEY \
CRON_SECRET=$CRON_SECRET \
NEXT_SHARP_PATH=/app/node_modules/sharp
RUN yarn turbo run build --filter=web
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.js