bun is a piece of shit, also, i'm ill i think

This commit is contained in:
zk
2026-05-04 18:19:38 +00:00
parent a784c8add6
commit 03ad9a7dfd
+22 -59
View File
@@ -4,6 +4,9 @@
# docker build -f docker/Dockerfile.server --target prod-api .
# docker build -f docker/Dockerfile.server --target prod-job-worker .
# docker build -f docker/Dockerfile.server --target prod-cron-worker .
#
# NOTE: bun build --compile is NOT used here because it's
# FUCKING BROKEN
FROM oven/bun:alpine AS base
WORKDIR /app
@@ -14,106 +17,66 @@ FROM base AS deps
COPY . .
RUN bun install --frozen-lockfile
# --- compile each entrypoint (inherits full /app from deps) ---
# Do not inline process.env at build time; standalone binary must read runtime env from the host.
# Do not auto-load dotenv inside the executable (orchestrator / loadServerEnvFile own that story).
FROM deps AS build-api
RUN mkdir -p /out && bun build \
--compile \
--env=disable \
--no-compile-autoload-dotenv \
--target=bun \
./typescript/server/src/main.ts \
--outfile /out/server
FROM deps AS build-job-worker
RUN mkdir -p /out && bun build \
--compile \
--env=disable \
--no-compile-autoload-dotenv \
--target=bun \
./typescript/server/src/job-queue-worker.ts \
--outfile /out/job-queue-worker
FROM deps AS build-cron-worker
RUN mkdir -p /out && bun build \
--compile \
--env=disable \
--no-compile-autoload-dotenv \
--target=bun \
./typescript/server/src/cron-worker.ts \
--outfile /out/cron-worker
# Runtime: `bun build --compile` links against libstdc++/libgcc; bare alpine:3.21 has neither.
# --- API image ---
FROM alpine:3.21 AS prod-api
FROM oven/bun:alpine AS prod-api
ARG COMMIT_HASH
ENV COMMIT_HASH=${COMMIT_HASH}
ENV MIGRATIONS_DIR=/app/db/migrations
ENV PORT=8080
RUN apk add --no-cache curl libstdc++ libgcc
RUN apk add --no-cache curl
COPY --from=build-api /out/server /server
COPY --from=deps /app/db/migrations /app/db/migrations
WORKDIR /app
COPY --from=deps /app .
EXPOSE 8080
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
CMD curl -sf http://localhost:8080/.deploy/up || exit 1
CMD ["/server"]
CMD ["bun", "run", "./typescript/server/src/main.ts"]
# --- Job queue worker (no HTTP port) ---
FROM alpine:3.21 AS prod-job-worker
FROM oven/bun:alpine AS prod-job-worker
ARG COMMIT_HASH
ENV COMMIT_HASH=${COMMIT_HASH}
ENV MIGRATIONS_DIR=/app/db/migrations
RUN apk add --no-cache curl libstdc++ libgcc
WORKDIR /app
COPY --from=deps /app .
COPY --from=build-job-worker /out/job-queue-worker /job-queue-worker
COPY --from=deps /app/db/migrations /app/db/migrations
CMD ["/job-queue-worker"]
CMD ["bun", "run", "./typescript/server/src/job-queue-worker.ts"]
# --- Cron worker (no HTTP port) ---
FROM alpine:3.21 AS prod-cron-worker
FROM oven/bun:alpine AS prod-cron-worker
ARG COMMIT_HASH
ENV COMMIT_HASH=${COMMIT_HASH}
ENV MIGRATIONS_DIR=/app/db/migrations
RUN apk add --no-cache curl libstdc++ libgcc
WORKDIR /app
COPY --from=deps /app .
COPY --from=build-cron-worker /out/cron-worker /cron-worker
COPY --from=deps /app/db/migrations /app/db/migrations
CMD ["bun", "run", "./typescript/server/src/cron-worker.ts"]
CMD ["/cron-worker"]
# --- All-in-one image for Kamal (web + job + cron roles share network with accessories) ---
FROM alpine:3.21 AS prod-unified
# --- All-in-one image.
FROM oven/bun:alpine AS prod-unified
ARG COMMIT_HASH
ENV COMMIT_HASH=${COMMIT_HASH}
ENV MIGRATIONS_DIR=/app/db/migrations
ENV PORT=8080
RUN apk add --no-cache curl libstdc++ libgcc
RUN apk add --no-cache curl
COPY --from=build-api /out/server /server
COPY --from=build-job-worker /out/job-queue-worker /job-queue-worker
COPY --from=build-cron-worker /out/cron-worker /cron-worker
COPY --from=deps /app/db/migrations /app/db/migrations
WORKDIR /app
COPY --from=deps /app .
EXPOSE 8080
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
CMD curl -sf http://localhost:8080/.deploy/up || exit 1
CMD ["/server"]
CMD ["bun", "run", "./typescript/server/src/main.ts"]