-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (54 loc) · 2.64 KB
/
Dockerfile
File metadata and controls
71 lines (54 loc) · 2.64 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
# syntax=docker/dockerfile:1
# ---- deps: install production dependencies only ----
FROM oven/bun:1.3.14-alpine AS deps
WORKDIR /app
# Copy only the manifests so this layer is cached unless deps change.
COPY package.json bun.lock ./
COPY apps/backend/package.json apps/backend/package.json
COPY packages/schemas/package.json packages/schemas/package.json
RUN bun install --frozen-lockfile --production
# ---- generate: full install + generate the API clients (gitignored) ----
FROM oven/bun:1.3.14-alpine AS generate
WORKDIR /app
COPY package.json bun.lock ./
COPY apps/backend/package.json apps/backend/package.json
COPY packages/schemas/package.json packages/schemas/package.json
# Full install here (openapi-ts is a devDependency).
RUN bun install --frozen-lockfile
COPY packages/schemas ./packages/schemas
RUN bun run --cwd packages/schemas openapi-ts
# ---- runtime ----
FROM oven/bun:1.3.14-alpine AS runtime
WORKDIR /app
ENV ENVIRONMENT=production \
NODE_ENV=production \
PORT=5225 \
APP_CONFIG_PATH=/config/config.jsonc
COPY package.json bun.lock ./
# Source first, then overlay the per-workspace node_modules from the deps
# stage. Bun installs into each workspace (no hoisting), and
# apps/backend/node_modules/@jack/schemas is a symlink into packages/schemas.
COPY packages/schemas ./packages/schemas
COPY apps/backend ./apps/backend
# Generated API clients are gitignored, so pull them from the generate stage.
COPY --from=generate /app/packages/schemas/src/generated ./packages/schemas/src/generated
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/packages/schemas/node_modules ./packages/schemas/node_modules
COPY --from=deps /app/apps/backend/node_modules ./apps/backend/node_modules
EXPOSE 5225
# Pre-create the config dir owned by the runtime user so jack can write the
# default config on first boot even when /config is a fresh named/anonymous
# volume. (Must come before VOLUME so the volume inherits the ownership.)
RUN mkdir -p /config && chown bun:bun /config
# Config lives outside the image so it survives rebuilds.
VOLUME ["/config"]
# Run as the image's non-root `bun` user (uid/gid 1000). This matches the
# PUID/PGID the *arr / linuxserver.io images default to, so files jack writes
# (e.g. finished downloads in the completed folder) are owned by the
# same user that imports them. Bind-mounted /config and download folders must
# therefore be readable/writable by uid 1000.
USER bun
# Hit the /ping endpoint to report container health.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -q -O /dev/null "http://localhost:${PORT}/ping" || exit 1
CMD ["bun", "apps/backend/src/index.ts"]