synor/docker/hosting-gateway/Dockerfile
Gulshan Yadav e23a56049c feat(hosting): add hosting gateway server with Docker deployment
Add HTTP server for Synor Hosting with:

- server/mod.rs: Gateway server using axum
- server/handler.rs: Request routing to storage, content type detection
- server/middleware.rs: Token bucket rate limiting, cache control, metrics
- server/ssl.rs: Let's Encrypt auto-provisioning (stub)
- bin/hosting-gateway.rs: CLI binary with env var config

Docker deployment:
- docker/hosting-gateway/Dockerfile: Multi-stage build
- docker/hosting-gateway/Caddyfile: Wildcard HTTPS for *.synor.cc
- docker-compose.hosting.yml: Full hosting stack with Caddy

37 tests passing.
2026-01-10 12:45:26 +05:30

55 lines
1.2 KiB
Docker

# Synor Hosting Gateway Docker Image
# Multi-stage build for optimized final image
FROM rust:1.75-slim-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Copy workspace files
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
# Build with release optimizations
RUN cargo build --release -p synor-hosting --features server --bin hosting-gateway
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -r -u 1000 synor
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/target/release/hosting-gateway /usr/local/bin/hosting-gateway
# Switch to non-root user
USER synor
# Default configuration
ENV LISTEN_ADDR=0.0.0.0:8080
ENV HOSTING_DOMAIN=synor.cc
ENV STORAGE_GATEWAY_URL=http://storage-gateway:80
ENV RATE_LIMIT=100
ENV RUST_LOG=info
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
ENTRYPOINT ["hosting-gateway"]