nano-web 0.12.1

🔥 Ultra-fast static file server built with Rust - 130k+ req/sec with pre-compressed in-memory caching
Documentation
# Multi-arch Dockerfile for nano-web
FROM --platform=${BUILDPLATFORM} rust:1.84-alpine AS builder

# Install build dependencies and cross-compilation tools
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

# Install build dependencies and add cross-compilation targets
RUN apk add --no-cache musl-dev gcc ca-certificates tzdata && \
    case ${TARGETARCH} in \
    "amd64")  TARGET=x86_64-unknown-linux-musl ;; \
    "arm64")  TARGET=aarch64-unknown-linux-musl ;; \
    *)        echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
    esac && \
    rustup target add ${TARGET} && \
    echo "${TARGET}" > /tmp/target

# Set working directory
WORKDIR /build

# Copy Cargo files first for better caching
COPY Cargo.toml Cargo.lock ./
COPY src src
COPY benches benches
COPY VERSION ./

# Build the binary with maximum optimizations for target architecture
RUN TARGET=$(cat /tmp/target) && \
    case ${TARGETARCH} in \
    "amd64")  RUSTFLAGS="-C target-cpu=x86-64-v3 -C target-feature=+crt-static -C codegen-units=1 -C panic=abort" ;; \
    "arm64")  RUSTFLAGS="-C target-cpu=generic -C target-feature=+crt-static -C codegen-units=1 -C panic=abort" ;; \
    esac && \
    cargo build --release --target ${TARGET} && \
    cp target/${TARGET}/release/nano-web /nano-web-bin

# Runtime stage - minimal scratch image
FROM scratch

# Copy CA certificates for HTTPS
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

# Copy the binary
COPY --from=builder /nano-web-bin /nano-web

# Set default environment variables
ENV PORT=3000
ENV SPA_MODE=0
ENV LOG_LEVEL=info
ENV LOG_FORMAT=json
ENV LOG_REQUESTS=true
ENV CONFIG_PREFIX=VITE_

# Create a default public directory
VOLUME ["/public"]

# Expose port
EXPOSE $PORT

# Set labels for better maintainability
LABEL org.opencontainers.image.title="nano-web"
LABEL org.opencontainers.image.description="Ultra-fast static file server built with Rust"
LABEL org.opencontainers.image.vendor="nano-web"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/radiosilence/nano-web"

# Run the binary
ENTRYPOINT ["/nano-web"]
CMD ["--dir", "/public"]