Hostityourself/infra/Dockerfile.server
Claude 0bd7b44b81
fix: drop cross-compilation, build natively in Dockerfile
podman-compose does not populate BUILDPLATFORM/TARGETARCH build args, so
the platform-detection logic always fell back to x86_64 — even on arm64.
This caused cc-rs to look for 'x86_64-linux-gnu-gcc' instead of 'gcc'.

Replace the entire cross-compile scaffolding with a plain native build:
  cargo build --release (no --target)

Cargo targets the host platform automatically. If cross-compilation is
ever needed it can be reintroduced with a properly-tested setup.

https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH
2026-03-24 16:25:48 +00:00

43 lines
1.6 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
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"]