-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (30 loc) · 1.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
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app
# OpenSSL is required for Prisma to work
RUN apt-get update -y && apt-get install -y openssl
# Set the CI environment variable to make the build stage omit husky hooks
ENV CI=true
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm db:generate
RUN pnpm run build
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
# Note: The index file here (
# /app/node_modules/@prisma/client
# ) imports .primsa/client - which is not present in the node_modules
# COPY --from=build /app/node_modules/@prisma/client /app/node_modules/@prisma/client
# Note: The COPY command above incomplete, for now we will install prisma
# in the final image, run the db:generate command and then ~~remove it again~~
# Edit: Yeah no, removing prisma breaks it - even though the generated client is still there
RUN pnpm i -D prisma
RUN pnpm db:generate
EXPOSE 9000
CMD [ "pnpm", "start" ]