sharenet/backend/Dockerfile
continuist 1eb4b61092
Some checks failed
Podman Rootless Demo / test-backend (push) Successful in 6m27s
Podman Rootless Demo / test-frontend (push) Successful in 11s
Podman Rootless Demo / build-backend (push) Failing after 5m22s
Podman Rootless Demo / build-frontend (push) Failing after 16s
Update backend Dockerfile to use rust base image that aligns with test stage
2025-09-20 12:48:45 -04:00

62 lines
No EOL
1.3 KiB
Docker

# Multi-stage build for Rust backend
FROM docker.io/rust:1.89-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy Cargo files
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
# Build dependencies first (for better caching)
RUN cargo build --release --bin sharenet-api-postgres
# Copy source code
COPY . .
# Build the application
RUN cargo build --release --bin sharenet-api-postgres
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
wget \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -r -s /bin/false sharenet
# Set working directory
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/target/release/sharenet-api-postgres /app/sharenet-api
# Copy configuration files
COPY --from=builder /app/config/ ./config/
# Change ownership
RUN chown -R sharenet:sharenet /app
# Switch to non-root user
USER sharenet
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/health || exit 1
# Run the application
CMD ["./sharenet-api"]