-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (56 loc) · 2.24 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (56 loc) · 2.24 KB
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
# ---- Builder ----------------------------------------------------------------
FROM node:24-trixie-slim AS builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV CI=true
# Provide a placeholder URL so `prisma generate` (called inside `pnpm run build`)
# can parse prisma.config.ts without a real database being present at build time.
ARG DATABASE_URL="postgresql://placeholder:placeholder@localhost:5432/placeholder?schema=public"
ENV DATABASE_URL=$DATABASE_URL
RUN corepack enable
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
libcurl4-openssl-dev \
libssl-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests before source for better layer caching.
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
# Activate the pinned package manager, then strip the husky prepare hook so
# pnpm install does not try to run it in a CI/Docker context.
RUN corepack install && pnpm pkg delete scripts.prepare
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
# ---- Runtime ----------------------------------------------------------------
FROM node:24-trixie-slim
LABEL org.opencontainers.image.source=https://github.com/LEDBrain/Community-Service
LABEL org.opencontainers.image.licenses=MIT
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV CI=true
ENV NODE_ENV=production
ENV PORT=3000
RUN corepack enable
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
libcurl4-openssl-dev \
libssl-dev \
build-essential \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Copy only the files needed at runtime.
COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./
COPY --from=builder /app/prisma.config.ts ./
COPY --from=builder /app/prisma ./prisma
# dist/src/ is the esbuild output; copy it so ./src/index.js is available.
COPY --from=builder /app/dist ./
RUN corepack install && pnpm pkg delete scripts.prepare
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod
COPY entrypoint.sh ./
RUN chmod +x ./entrypoint.sh
EXPOSE 3000
USER node
ENTRYPOINT ["./entrypoint.sh"]