Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (43 loc) · 1.77 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# syntax=docker/dockerfile:1
# --- Cross-compilation helper ---
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
# --- Stage 1: Build frontend (native, output is platform-independent) ---
FROM --platform=$BUILDPLATFORM node:26-alpine AS frontend-build
ARG HALO_IMAGE_TAG
ENV VITE_HALO_IMAGE_TAG=$HALO_IMAGE_TAG
WORKDIR /app
COPY frontend/package.json frontend/yarn.lock frontend/.yarnrc.yml* ./
# .yarnrc.yml pins yarnPath to a committed release; copy it in before install
COPY frontend/.yarn/ ./.yarn/
# Invoke the vendored yarn through node — no corepack (node 25+ dropped the
# bundle), so this stage stays independent of the node version.
RUN node .yarn/releases/yarn-*.cjs install --immutable --network-timeout 1000000
COPY frontend/ .
RUN node .yarn/releases/yarn-*.cjs build
# --- Stage 2: Build backend dependencies (native, cross-compiled) ---
FROM --platform=$BUILDPLATFORM rust:1-alpine AS backend-deps
COPY --from=xx / /
RUN apk add --no-cache clang lld musl-dev curl
ARG TARGETPLATFORM
RUN xx-apk add --no-cache musl-dev gcc
WORKDIR /app
COPY backend/Cargo.toml backend/Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs \
&& xx-cargo build --release \
&& rm -rf src
# --- Stage 3: Build backend ---
FROM backend-deps AS backend-build
ARG TARGETPLATFORM
COPY backend/src ./src
RUN touch src/main.rs && xx-cargo build --release
# --- Stage 4: Runtime ---
FROM scratch AS runner
WORKDIR /app
LABEL org.opencontainers.image.description="halo for raspi"
LABEL org.opencontainers.image.source="https://github.com/eetu/halo"
COPY --from=backend-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=backend-build /app/target/*/release/halo-backend ./halo-backend
COPY --from=frontend-build /app/dist ./dist
USER 1000
EXPOSE 3000
CMD ["./halo-backend"]