-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
61 lines (49 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
61
FROM oven/bun:slim AS base
FROM base AS dual
WORKDIR /temp
RUN apt-get -y update; apt-get -y install curl
# we need to use node and bun for generating prisma files, see https://github.com/prisma/prisma/issues/21241
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash
RUN apt-get install -y nodejs
FROM dual AS builder
WORKDIR /app
ARG VERSION
ENV PUBLIC_VERSION=$VERSION
ARG SHA
ENV PUBLIC_SHA=$SHA
COPY package.json bun.lockb tsconfig.json ./
RUN bun install --frozen-lockfile
# we need to generate prisma files before building to prevent type errors
COPY ./prisma/migrations ./prisma/migrations/
COPY ./prisma/schema.prisma ./prisma/schema.prisma
RUN bunx prisma generate
COPY . .
# the build command generates a few things, such as i18n outputs
# therefore we need to run the build command BEFORE we check for correctness
RUN bun run build
RUN bun run check
# remove all dependencies which are unused
# TODO https://github.com/oven-sh/bun/issues/3605
FROM base AS release
WORKDIR /app
ARG VERSION
ENV PUBLIC_VERSION=$VERSION
ARG SHA
ENV PUBLIC_SHA=$SHA
# the runtime dependencies
COPY --from=builder /app/node_modules ./node_modules/
# the sveltekit output
COPY --from=builder /app/build .
# the tasks build output
COPY --from=builder /app/tasksOut .
# the prisma schema and migrations
COPY --from=builder /app/prisma ./prisma/
# Make a folder called /app/ephemeralData
RUN mkdir /app/ephemeralData
# Change ownership to the bun user
RUN chown -R bun:bun /app/node_modules /app/prisma /app/ephemeralData
ENV NODE_ENV=production
USER bun
EXPOSE 3000/tcp
# HEALTHCHECK --interval=15s --timeout=10s --retries=3 CMD curl -f http://0.0.0.0:3000/api/health/ready || exit 1
CMD bunx prisma migrate deploy && bun run start