-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 1.7 KB
/
Copy pathDockerfile
File metadata and controls
40 lines (31 loc) · 1.7 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
# ── Build ────────────────────────────────────────────────────────────────────
FROM oven/bun:1-debian AS build
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY tsconfig.json vite.config.ts index.html ./
COPY public/ public/
COPY src/ src/
COPY scripts/backup.ts scripts/backup.ts
RUN bun run build
RUN bun build src/server/index.ts --target bun --outfile dist/server.js
# Shipped so `docker exec presto bun dist/backup.js` works without the source tree.
RUN bun build scripts/backup.ts --target bun --outfile dist/backup.js
# ── Runtime ──────────────────────────────────────────────────────────────────
# The server is a single bundled file and SQLite is built into Bun, so the
# runtime image carries no node_modules at all.
FROM oven/bun:1-alpine
WORKDIR /app
RUN addgroup -S -g 1001 presto \
&& adduser -S -u 1001 -G presto -H presto \
&& mkdir -p /data && chown presto:presto /data
COPY --from=build --chown=presto:presto /app/dist/server.js dist/server.js
COPY --from=build --chown=presto:presto /app/dist/backup.js dist/backup.js
COPY --from=build --chown=presto:presto /app/dist/ui dist/ui
ENV PORT=8080 DATA_DIR=/data
EXPOSE 8080
VOLUME ["/data"]
USER presto
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD bun -e "fetch('http://localhost:'+(process.env.PORT||8080)+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["bun", "dist/server.js"]