forked from compsci-adl/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (43 loc) · 1.7 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
# Cache package.json
FROM node:20-bookworm-slim AS deps
WORKDIR /tmp
COPY package.json ./
# Build
FROM node:20-bookworm-slim AS builder
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
ENV SKIP_ENV_VALIDATION=true
WORKDIR /app
COPY --from=deps /tmp ./
COPY pnpm-lock.yaml ./
RUN npm install -g pnpm \
&& pnpm install
COPY . .
# Needed for build
ENV NEXT_PUBLIC_CLERK_SIGN_IN_URL=/signin
ENV NEXT_PUBLIC_CLERK_SIGN_UP_URL=/join
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
RUN --mount=type=secret,id=DATABASE_URL,target=/run/secrets/DATABASE_URL \
--mount=type=secret,id=REDIS_URI,target=/run/secrets/REDIS_URI \
--mount=type=secret,id=NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,target=/run/secrets/NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \
--mount=type=secret,id=NEXT_PUBLIC_DRIVE_LINK,target=/run/secrets/NEXT_PUBLIC_DRIVE_LINK \
--mount=type=secret,id=NEXT_PUBLIC_UMAMI_WEBSITE_ID,target=/run/secrets/NEXT_PUBLIC_UMAMI_WEBSITE_ID \
DATABASE_URL=$(cat /run/secrets/DATABASE_URL) \
REDIS_URI=$(cat /run/secrets/REDIS_URI) \
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=$(cat /run/secrets/NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY) \
NEXT_PUBLIC_DRIVE_LINK=$(cat /run/secrets/NEXT_PUBLIC_DRIVE_LINK) \
NEXT_PUBLIC_UMAMI_WEBSITE_ID=$(cat /run/secrets/NEXT_PUBLIC_UMAMI_WEBSITE_ID) \
pnpm run build
# Final deployment image
FROM node:20-bookworm-slim AS runner
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
ENV NODE_ENV=production
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
RUN npm install -g pnpm
WORKDIR /app
COPY --from=builder /app /app
EXPOSE $PORT
CMD [ "pnpm", "run", "start" ]