fix(docker): Update to Rust 1.93 to support Edition 2024
This commit is contained in:
parent
860c2dc439
commit
d63f160af3
5 changed files with 176 additions and 9 deletions
|
|
@ -1,15 +1,46 @@
|
|||
FROM rust:latest AS builder
|
||||
# Production Dockerfile (Multi-stage build)
|
||||
# Stage 1: Build
|
||||
FROM rust:1.93-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache musl-dev pkgconf openssl-dev
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy Cargo files first for better caching
|
||||
COPY Cargo.toml ./
|
||||
|
||||
# Create dummy main.rs for dependency caching
|
||||
RUN mkdir src && echo 'fn main() {}' > src/main.rs
|
||||
|
||||
# Build dependencies (this layer will be cached)
|
||||
RUN cargo build --release && rm -rf src
|
||||
|
||||
# Copy actual source code
|
||||
COPY src ./src
|
||||
|
||||
# Build the actual application
|
||||
RUN cargo build --release
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache ca-certificates
|
||||
COPY --from=builder /app/target/release/normogen-backend /usr/local/bin/normogen-backend
|
||||
EXPOSE 8000
|
||||
CMD ["./normogen-backend"]
|
||||
# Stage 2: Runtime
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install runtime dependencies only
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
libssl3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the binary from builder stage
|
||||
COPY --from=builder /app/target/release/normogen-backend /usr/local/bin/normogen-backend
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Run the application
|
||||
CMD ["./normogen-backend"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue