forked from ndom91/sveltekasten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
76 lines (57 loc) · 1.78 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
###########################
# BASE CONTAINER #
###########################
FROM node:lts-bookworm-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Enable pnpm
RUN corepack enable
###########################
# BUILDER CONTAINER #
###########################
FROM base AS build
COPY . /app
WORKDIR /app
RUN mkdir -p /prod/web \
&& mkdir -p /prod/backend
# Install openssl for prisma
RUN apt-get update -qq \
&& apt-get install -y openssl git
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# Generate prisma client
RUN cd apps/backend && pnpm exec prisma generate && pnpm exec prisma generate
RUN cd apps/web && pnpm exec prisma generate
RUN pnpm run -r build \
&& pnpm deploy --filter=sveltekasten-web --prod /prod/web \
&& pnpm deploy --filter=sveltekasten-backend --prod /prod/backend
###########################
# WEB CONTAINER #
###########################
FROM base AS web
ENV NODE_ENV production
# Install openssl for prisma
RUN apt-get update -qq \
&& apt-get install -y openssl
COPY --chown=node:node --from=build /prod/web /prod/web
# Generate prisma client and push db schema
RUN cd /prod/web \
&& pnpm dlx prisma generate
WORKDIR /prod/web
EXPOSE ${PORT:-3000}
CMD [ "pnpm", "start" ]
###########################
# BACKEND CONTAINER #
###########################
FROM base AS backend
ENV NODE_ENV production
# Install openssl for prisma
RUN apt-get update -qq \
&& apt-get install -y openssl
COPY --chown=node:node --from=build /prod/backend /prod/backend
# Generate prisma client and install playwright chromium + deps
RUN cd /prod/backend \
&& pnpm dlx prisma generate \
&& pnpm exec playwright install --with-deps chromium
WORKDIR /prod/backend
EXPOSE ${PORT:-8000}
CMD [ "pnpm", "start" ]