Files
web-at-transit/backend/Dockerfile
T
phattaranun.a 37711a0a8a fix(backend): cap cargo parallelism to 1 for the VPS build
CARGO_BUILD_JOBS=2 on the 1-vCPU VPS spiked load (~30) and destabilised
the swarm during deploy (health checks timed out, Dokploy restarted and
killed the build). Build with a single job; combined with the 4 GB
swapfile added on the host this keeps the build from starving services.
2026-10-10 17:14:38 +07:00

20 lines
778 B
Docker

# syntax=docker/dockerfile:1.7
# rustc 1.89+ required: latest transitive deps (e.g. uuid 1.28) set MSRV 1.89.
# No Cargo.lock is committed, so the resolver picks the newest crates on every
# build — keep this tag >= the current MSRV of the dependency tree.
FROM rust:1.90-bookworm AS builder
WORKDIR /build
ENV CARGO_BUILD_JOBS=1
COPY Cargo.toml Cargo.lock* ./
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
COPY . .
RUN touch src/main.rs && cargo build --release
FROM debian:12-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /build/target/release/backend /app/backend
ENV BIND_ADDR=0.0.0.0:8080
EXPOSE 8080
CMD ["/app/backend"]