Files
zkldi_Tachi/docker/Dockerfile.server
T
2026-03-18 20:20:03 +00:00

49 lines
1.3 KiB
Docker

# Build context must be the repo root.
# docker build -f deploy/docker/Dockerfile.server .
FROM oven/bun:alpine AS base
WORKDIR /app
# --- deps: install ALL deps (dev included, needed for the build) ---
FROM base AS deps
COPY package.json bun.lock bunfig.toml ./
COPY patches ./patches
COPY typescript/server/package.json ./typescript/server/
COPY typescript/common/package.json ./typescript/common/
COPY typescript/db/package.json ./typescript/db/
COPY typescript/db-migration-engine/package.json ./typescript/db-migration-engine/
RUN bun install --frozen-lockfile
# --- build: compile everything into a single native binary ---
FROM deps AS build
COPY typescript/server ./typescript/server
COPY typescript/common ./typescript/common
COPY typescript/db ./typescript/db
COPY typescript/db-migration-engine ./typescript/db-migration-engine
COPY package.json bunfig.toml ./
RUN bun build \
--compile \
--target=bun \
./typescript/server/src/main.ts \
--outfile /server
# --- prod: nothing but the binary ---
FROM alpine:3.21 AS prod
ARG COMMIT_HASH
ENV COMMIT_HASH=${COMMIT_HASH}
RUN apk add --no-cache curl
COPY --from=build /server /server
HEALTHCHECK --interval=15s --timeout=5s \
CMD curl -sf http://localhost:8080/.deploy/up || exit 1
CMD ["/server"]