buster/apps/api/Dockerfile

40 lines
943 B
Docker
Raw Normal View History

2025-01-04 05:32:54 +08:00
FROM lukemathwalker/cargo-chef AS chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin buster_server
2025-01-04 05:32:54 +08:00
FROM debian:bookworm-slim AS runtime
WORKDIR /app
RUN apt-get update && apt-get install -y \
ca-certificates \
openssh-client \
curl \
unzip \
libpq5 \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
2025-01-10 08:27:39 +08:00
# Create PostgreSQL cert directory
RUN mkdir -p /root/.postgresql
# Handle certs
COPY cert.pem* /usr/local/share/ca-certificates/cert.crt
2025-01-10 08:27:39 +08:00
COPY cert.pem* /root/.postgresql/root.crt
RUN update-ca-certificates
2025-01-10 07:58:06 +08:00
2025-03-19 12:41:29 +08:00
# Set production environment variables
ENV RUST_LOG=warn
ENV RUST_BACKTRACE=0
COPY --from=builder /app/target/release/buster_server .
2025-01-04 05:32:54 +08:00
EXPOSE 3001
ENTRYPOINT ["./buster_server"]