# =============================================================================
# Horkos Docker Image
# =============================================================================
# Multi-stage build for minimal image size
#
# Usage:
#   docker run --rm -v $(pwd):/workspace ghcr.io/aimable100/horkos compile
#
# =============================================================================

# Build stage
FROM rust:1.75-slim-bookworm AS builder

WORKDIR /build

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

# Copy source
COPY . .

# Build release binary
RUN cargo build --release --locked

# Runtime stage
FROM debian:bookworm-slim

# Labels for GitHub Container Registry
LABEL org.opencontainers.image.source="https://github.com/aimable100/horkos"
LABEL org.opencontainers.image.description="Infrastructure language where insecure code won't compile"
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0"

# Install CA certificates for HTTPS
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Copy binary from builder
COPY --from=builder /build/target/release/horkos /usr/local/bin/horkos

# Create non-root user
RUN useradd -m -s /bin/bash horkos
USER horkos

# Set working directory
WORKDIR /workspace

# Default command
ENTRYPOINT ["horkos"]
CMD ["--help"]

