blog/backend/Dockerfile
SquidSpirit 5a30642b8f
All checks were successful
Frontend CI / build (push) Successful in 1m5s
PR Title Check / pr-title-check (pull_request) Successful in 13s
Auto Comment On PR / add_improve_comment (pull_request) Successful in 13s
BLOG-78 feat: add volume and storage path for static files in Dockerfile
2025-07-27 12:22:11 +08:00

25 lines
630 B
Docker

FROM rust:1-slim AS base
RUN apt update -qq && apt install -y -qq --no-install-recommends musl-tools
RUN rustup target add x86_64-unknown-linux-musl
FROM base AS builder
WORKDIR /app
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl
FROM alpine:latest AS runner
WORKDIR /app
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/server .
EXPOSE 8080
VOLUME ["/app/static"]
ENV RUST_LOG=info
ENV HOST=0.0.0.0
ENV PORT=8080
ENV STORAGE_PATH=/app/static
ENV DATABASE_HOST=127.0.0.1
ENV DATABASE_PORT=5432
ENV DATABASE_USER=postgres
ENV DATABASE_PASSWORD=
ENV DATABASE_NAME=postgres
CMD ["./server"]