-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (40 loc) · 1.44 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
FROM node:20-alpine AS base
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry
# ENV NEXT_TELEMETRY_DISABLED 1
RUN apk add --no-cache yarn
WORKDIR /usr/src/app
FROM base AS install-build
RUN mkdir -p /temp/install-build
COPY package.json yarn.lock .yarnrc.yml /temp/install-build/
COPY .yarn/releases/yarn-*.cjs /temp/install-build/.yarn/releases/
RUN cd /temp/install-build && yarn install --immutable
FROM base AS install-run
RUN mkdir -p /temp/install-run
COPY package.json yarn.lock .yarnrc.yml /temp/install-run/
COPY .yarn/releases/yarn-*.cjs /temp/install-run/.yarn/releases/
RUN cd /temp/install-run && yarn workspaces focus --production
FROM base AS build
COPY --from=install-build /temp/install-build/node_modules node_modules
COPY . .
ARG NEXT_PUBLIC_FRONTEND_URL
ARG NEXT_PUBLIC_OPENAI_SYNTAX_DETECTION
ENV BUILD_TIME=True
RUN yarn run build
FROM base AS run
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=build --chown=nextjs:nodejs /usr/src/app/.next ./.next
COPY --from=install-run --chown=nextjs:nodejs /temp/install-run/node_modules node_modules
COPY --chown=nextjs:nodejs . .
USER nextjs
ENV HOST=0.0.0.0
ARG DATABASE_URL
ENV DATABASE_URL=${DATABASE_URL}
ARG OPENAI_API_KEY
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
ARG PORT
ENV PORT=${PORT:-3000}
EXPOSE ${PORT}
ENV BUILD_TIME=False
ENTRYPOINT ["sh", "-c", "node drizzle/migrate.mjs && yarn run start"]