Files
corrosion-admin-panel/docker/Dockerfile.api
Vantz Stockwell 2c3688c914 fix: Make Cargo.lock optional in Docker build
Cargo.lock may not exist before first build. Use wildcard copy
so Docker doesn't fail if lockfile is missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:45:04 -05:00

35 lines
777 B
Docker

# Multi-stage build for Corrosion API
# Stage 1: Build the Rust binary
FROM rust:1.84-alpine AS builder
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static
WORKDIR /build
# Cache dependencies — copy manifests first
COPY Cargo.toml ./
COPY Cargo.lock* ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release 2>/dev/null || true
# Now copy actual source and build
COPY src/ src/
COPY migrations/ migrations/
RUN touch src/main.rs && cargo build --release
# Stage 2: Runtime image
FROM alpine:3.20
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY --from=builder /build/target/release/corrosion-api .
COPY migrations/ migrations/
ENV RUST_LOG=corrosion_api=info,tower_http=info
EXPOSE 3000
CMD ["./corrosion-api"]