generated from dreampipcom/nexus
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
268 lines (215 loc) · 7.03 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
ARG NEXUS_STANDALONE
ENV NEXUS_STANDALONE=$NEXUS_STANDALONE
# Install dependencies based on the preferred package manager
RUN mkdir -p ./prisma
COPY prisma/schema-* ./prisma
RUN mkdir -p ./patches
COPY patches/* ./patches
COPY postInstall.js ./
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
ARG NEXUS_STANDALONE
ENV NEXUS_STANDALONE=$NEXUS_STANDALONE
COPY --from=deps /app/node_modules ./node_modules
COPY . .
COPY --from=deps /app/package.json /app/yarn.lock* /app/package-lock.json* /app/pnpm-lock.yaml* ./
COPY --from=deps /app/prisma/schema-* ./prisma
RUN npm run schema:generate:all:standalone
# 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 during the build.
ENV NEXT_TELEMETRY_DISABLED 1
# ARGS VARS
ARG AUTH_GITHUB_ID
ARG AUTH_GITHUB_SECRET
ARG GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG INSTAGRAM_CLIENT_ID
ARG INSTAGRAM_CLIENT_SECRET
ARG FACEBOOK_CLIENT_ID
ARG FACEBOOK_CLIENT_SECRET
ARG APPLE_CLIENT_ID
ARG APPLE_CLIENT_SECRET
ARG EMAIL_FROM
ARG EMAIL_SERVER
ARG AUTH_TRUST_HOST
ARG AUTH_SECRET
ARG AUTH_URL
ARG MAIN_URL
ARG API_URL
ARG KV_REST_API_READ_ONLY_TOKEN
ARG KV_REST_API_TOKEN
ARG KV_REST_API_URL
ARG KV_URL
ARG MONGODB_DATABASE
ARG MONGODB_USERS_DATABASE
ARG MONGODB_ORGS_DATABASE
ARG MONGODB_DEFAULT_ORG
ARG PRISMA_PRIVATE_URI
ARG MONGODB_PRIVATE_URI
ARG PRISMA_PUBLIC_URI
ARG MONGODB_PUBLIC_URI
ARG NEXUS_MODE
ARG NEXUS_KEEPALIVE
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_PROJECT
ARG SENTRY_ORG
ARG NEXT_PUBLIC_SENTRY_DSN
ARG VERCEL_GIT_COMMIT_SHA
# ENV FROM ARGS VARS
ENV AUTH_GITHUB_ID=$AUTH_GITHUB_ID
ENV AUTH_GITHUB_SECRET=$AUTH_GITHUB_SECRET
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET
ENV INSTAGRAM_CLIENT_ID=$INSTAGRAM_CLIENT_ID
ENV INSTAGRAM_CLIENT_SECRET=$INSTAGRAM_CLIENT_SECRET
ENV FACEBOOK_CLIENT_ID=$FACEBOOK_CLIENT_ID
ENV FACEBOOK_CLIENT_SECRET=$FACEBOOK_CLIENT_SECRET
ENV APPLE_CLIENT_ID=$APPLE_CLIENT_ID
ENV APPLE_CLIENT_SECRET=$APPLE_CLIENT_SECRET
ENV EMAIL_FROM=$EMAIL_FROM
ENV EMAIL_SERVER=$EMAIL_SERVER
ENV AUTH_TRUST_HOST=$AUTH_TRUST_HOST
ENV AUTH_SECRET=$AUTH_SECRET
ENV AUTH_URL=$AUTH_URL
ENV MAIN_URL=$MAIN_URL
ENV API_URL=$API_URL
ENV KV_REST_API_READ_ONLY_TOKEN=$KV_REST_API_READ_ONLY_TOKEN
ENV KV_REST_API_TOKEN=$KV_REST_API_TOKEN
ENV KV_REST_API_URL=$KV_REST_API_URL
ENV KV_URL=$KV_URL
ENV MONGODB_DATABASE=$MONGODB_DATABASE
ENV MONGODB_USERS_DATABASE=$MONGODB_USERS_DATABASE
ENV MONGODB_ORGS_DATABASE=$MONGODB_ORGS_DATABASE
ENV MONGODB_DEFAULT_ORG=$MONGODB_DEFAULT_ORG
ENV PRISMA_PRIVATE_URI=$PRISMA_PRIVATE_URI
ENV MONGODB_PRIVATE_URI=$MONGODB_PRIVATE_URI
ENV PRISMA_PUBLIC_URI=$PRISMA_PUBLIC_URI
ENV MONGODB_PUBLIC_URI=$MONGODB_PUBLIC_URI
ENV NEXUS_MODE=$NEXUS_MODE
ENV NEXUS_KEEPALIVE=$NEXUS_KEEPALIVE
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_PROJECT=$SENTRY_PROJECT
ENV SENTRY_ORG=$SENTRY_ORG
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
ENV VERCEL_GIT_COMMIT_SHA=$VERCEL_GIT_COMMIT_SHA
RUN \
if [ -f yarn.lock ]; then yarn run build:vm; \
elif [ -f package-lock.json ]; then npm run build:vm; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build:vm; \
else echo "Lockfile not found." && exit 1; \
fi
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ARG NEXUS_STANDALONE
ENV NEXUS_STANDALONE=$NEXUS_STANDALONE
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1
# ARGS VARS
ARG AUTH_GITHUB_ID
ARG AUTH_GITHUB_SECRET
ARG GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG INSTAGRAM_CLIENT_ID
ARG INSTAGRAM_CLIENT_SECRET
ARG FACEBOOK_CLIENT_ID
ARG FACEBOOK_CLIENT_SECRET
ARG APPLE_CLIENT_ID
ARG APPLE_CLIENT_SECRET
ARG EMAIL_FROM
ARG EMAIL_SERVER
ARG AUTH_TRUST_HOST
ARG AUTH_SECRET
ARG AUTH_URL
ARG MAIN_URL
ARG API_URL
ARG KV_REST_API_READ_ONLY_TOKEN
ARG KV_REST_API_TOKEN
ARG KV_REST_API_URL
ARG KV_URL
ARG MONGODB_DATABASE
ARG MONGODB_USERS_DATABASE
ARG MONGODB_ORGS_DATABASE
ARG MONGODB_DEFAULT_ORG
ARG PRISMA_PRIVATE_URI
ARG MONGODB_PRIVATE_URI
ARG PRISMA_PUBLIC_URI
ARG MONGODB_PUBLIC_URI
ARG NEXUS_MODE
ARG NEXUS_KEEPALIVE
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_PROJECT
ARG SENTRY_ORG
ARG NEXT_PUBLIC_SENTRY_DSN
ARG VERCEL_GIT_COMMIT_SHA
# ENV FROM ARGS VARS
ENV AUTH_GITHUB_ID=$AUTH_GITHUB_ID
ENV AUTH_GITHUB_SECRET=$AUTH_GITHUB_SECRET
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET
ENV INSTAGRAM_CLIENT_ID=$INSTAGRAM_CLIENT_ID
ENV INSTAGRAM_CLIENT_SECRET=$INSTAGRAM_CLIENT_SECRET
ENV FACEBOOK_CLIENT_ID=$FACEBOOK_CLIENT_ID
ENV FACEBOOK_CLIENT_SECRET=$FACEBOOK_CLIENT_SECRET
ENV APPLE_CLIENT_ID=$APPLE_CLIENT_ID
ENV APPLE_CLIENT_SECRET=$APPLE_CLIENT_SECRET
ENV EMAIL_FROM=$EMAIL_FROM
ENV EMAIL_SERVER=$EMAIL_SERVER
ENV AUTH_TRUST_HOST=$AUTH_TRUST_HOST
ENV AUTH_SECRET=$AUTH_SECRET
ENV AUTH_URL=$AUTH_URL
ENV MAIN_URL=$MAIN_URL
ENV API_URL=$API_URL
ENV KV_REST_API_READ_ONLY_TOKEN=$KV_REST_API_READ_ONLY_TOKEN
ENV KV_REST_API_TOKEN=$KV_REST_API_TOKEN
ENV KV_REST_API_URL=$KV_REST_API_URL
ENV KV_URL=$KV_URL
ENV MONGODB_DATABASE=$MONGODB_DATABASE
ENV MONGODB_USERS_DATABASE=$MONGODB_USERS_DATABASE
ENV MONGODB_ORGS_DATABASE=$MONGODB_ORGS_DATABASE
ENV MONGODB_DEFAULT_ORG=$MONGODB_DEFAULT_ORG
ENV PRISMA_PRIVATE_URI=$PRISMA_PRIVATE_URI
ENV MONGODB_PRIVATE_URI=$MONGODB_PRIVATE_URI
ENV PRISMA_PUBLIC_URI=$PRISMA_PUBLIC_URI
ENV MONGODB_PUBLIC_URI=$MONGODB_PUBLIC_URI
ENV NEXUS_MODE=$NEXUS_MODE
ENV NEXUS_KEEPALIVE=$NEXUS_KEEPALIVE
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_PROJECT=$SENTRY_PROJECT
ENV SENTRY_ORG=$SENTRY_ORG
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
ENV VERCEL_GIT_COMMIT_SHA=$VERCEL_GIT_COMMIT_SHA
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/pm2-vm.json ./
RUN npm i -g pm2
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3001
ENV PORT=3001
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD [ "npm", "run", "start:vm:pm2" ]