normogen/backend/docker/Dockerfile
goose 2231cc11c8
Some checks failed
Lint and Build / Lint (push) Failing after 2s
Lint and Build / Build (push) Has been skipped
Lint and Build / Docker Build (push) Has been skipped
Fix Dockerfile - Use /app/ directory for binary
2026-03-05 10:17:28 -03:00

48 lines
1 KiB
Docker

# Production Dockerfile (Multi-stage build)
# Stage 1: Build
FROM rust:1.93-slim AS builder
WORKDIR /app
# 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
# 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 /app/normogen-backend
# Expose port
EXPOSE 8000
# Make the binary executable and run it
RUN chmod +x /app/normogen-backend
CMD ["/app/normogen-backend"]