# Ultra-fast image using pre-compiled binaries where possible
# Build time: ~2-3 min (vs ~20 min compiling from source)
# Size: ~600-700MB
#
# Build: docker build -t your-registry/typedialog-ci:prebuilt -f .woodpecker/Dockerfile.prebuilt .

FROM rust:1.92-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    shellcheck \
    curl \
    git \
    ca-certificates \
    wget \
    xz-utils \
    && rm -rf /var/lib/apt/lists/*

# Install Rust components
RUN rustup component add clippy rustfmt

# Install just (pre-compiled)
RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin

# Install cargo-binstall for faster binary installations
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

# Install Rust tools using pre-compiled binaries (much faster, smaller)
RUN cargo binstall --no-confirm \
    cargo-audit \
    cargo-deny \
    cargo-sbom

# These need to be compiled (no pre-built binaries available)
RUN cargo install --locked nickel-lang-cli nu

# Clean up cargo cache to reduce size
RUN rm -rf /usr/local/cargo/registry \
    && rm -rf /usr/local/cargo/git

# Set working directory
WORKDIR /workspace

# Verify installations
RUN just --version && \
    cargo --version && \
    cargo audit --version && \
    cargo deny --version && \
    cargo sbom --version && \
    nickel --version && \
    nu --version

# Show final size breakdown
RUN du -sh /usr/local/cargo/bin/*
