-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile.tasks
More file actions
86 lines (71 loc) · 3.25 KB
/
Dockerfile.tasks
File metadata and controls
86 lines (71 loc) · 3.25 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
80
81
82
83
84
85
86
# =============================================================================
# Dockerfile.tasks — Dedicated image for background tasks (mail sync, cron jobs)
# =============================================================================
# Produces a minimal image that only runs tasksMain.js via bun.
# The main SvelteKit app image (Dockerfile) handles migrations on startup;
# this container assumes the database is already migrated.
# =============================================================================
# ---------------------------------------------------------------------------
# Stage 0: shared base
# ---------------------------------------------------------------------------
FROM oven/bun:1.3-slim AS base
# ---------------------------------------------------------------------------
# Stage 1: install Node.js (needed for prisma generate)
# ---------------------------------------------------------------------------
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_24.x | bash
RUN apt-get install -y nodejs
# ---------------------------------------------------------------------------
# Stage 2: build the tasks bundle with tsup
# ---------------------------------------------------------------------------
FROM dual AS builder
WORKDIR /build
COPY package.json bun.lock tsconfig.json svelte.config.js ./
COPY prisma ./prisma
COPY project.inlang ./project.inlang
COPY messages ./messages
COPY src ./src
COPY scripts ./scripts
COPY static ./static
RUN bun install --frozen-lockfile
# Generate path aliases (.svelte-kit/tsconfig.json) that tsconfig.json extends
RUN bunx svelte-kit sync
# Generate Prisma client + query engine for linux
RUN bunx prisma generate
# Generate i18n runtime (imported by conferenceStatus task)
RUN bunx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide --strategy url baseLocale
# Bundle tasks into a single file
RUN bun run build:tasks
# ---------------------------------------------------------------------------
# Stage 3: minimal runtime
# ---------------------------------------------------------------------------
FROM base AS runner
WORKDIR /run
# Install only the npm packages that tsup externalizes and tasks import at runtime.
# Keep versions in sync with the main package.json devDependencies.
# Packages:
# @prisma/client — DB ORM
# node-schedule — cron scheduling
# @slack/webhook — error/status notifications
# zod — config validation
# dayjs — date handling
# openapi-fetch — Listmonk API client
RUN bun add \
@prisma/client@^6.19.0 \
node-schedule@^2.1.1 \
@slack/webhook@^7.0.7 \
zod@^4.1.13 \
dayjs@^1.11.19 \
openapi-fetch@^0.13.8
# Copy generated Prisma query engine binary from builder
COPY --from=builder /build/node_modules/.prisma ./node_modules/.prisma
# Copy the bundled tasks entrypoint
COPY --from=builder /build/tasksOut/tasksMain.js ./tasksMain.js
# Create writable directory for conference status historic stats
RUN mkdir /run/ephemeralData && chown -R bun:bun /run/ephemeralData
USER bun
ENV NODE_ENV=production
CMD ["bun", "./tasksMain.js"]