Hostityourself/infra/Dockerfile.server
Claude 60f5df52f7
fix: copy server/templates into build image for include_str! macros
include_str!("../../templates/...") is resolved at compile time, so the
template files must be present in the Docker build context. The previous
Dockerfile only copied server/src, not server/templates.

https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH
2026-03-24 16:29:15 +00:00

44 lines
1.7 KiB
Text

# syntax=docker/dockerfile:1
# ── Build stage ───────────────────────────────────────────────────────────────
# Native build: Cargo targets the host platform automatically.
# No --target flag means no cross-compiler confusion regardless of which
# arch podman-compose runs on (x86_64, arm64, armv7…).
FROM docker.io/library/rust:1.94-slim-bookworm AS builder
# gcc is required by cc-rs (used by aes-gcm / ring build scripts).
# rust:slim does not include a C compiler.
RUN apt-get update && apt-get install -y gcc pkg-config && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Cache dependency compilation separately from application source.
COPY Cargo.toml Cargo.lock* ./
COPY server/Cargo.toml ./server/
RUN mkdir -p server/src && echo 'fn main(){}' > server/src/main.rs
RUN cargo build --release -p hiy-server 2>/dev/null || true
RUN rm -f server/src/main.rs
# Build actual source.
COPY server/src ./server/src
COPY server/templates ./server/templates
RUN touch server/src/main.rs && \
cargo build --release -p hiy-server
# ── Runtime stage ─────────────────────────────────────────────────────────────
FROM docker.io/library/debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
git \
curl \
bash \
python3 \
podman \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/target/release/hiy-server /usr/local/bin/hiy-server
WORKDIR /app
CMD ["hiy-server"]