# syntax=docker/dockerfile:1
#
# Reproducible Windows bundle build on a Linux host.
#
# This image never touches the app's own Dockerfile or compose file; it exists
# so the optional Windows artifact (including Luminary.exe, which needs Go) can
# be produced from this machine:
#
#   docker build -f windows/Dockerfile --output type=local,dest=/tmp/luminary-win .
#
# The output directory must be outside the checkout (see windows/README.md).
# BuildKit is required for --output.
#
# `--output` exports the "artifacts" stage, which is `scratch`: only the bundle
# zip, its checksum and the staged tree are copied out.

FROM node:24-bookworm AS build
COPY --from=golang:1.23-bookworm /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"

WORKDIR /src
COPY . .

# Build-time dependencies for vite and tsc; the Windows runtime dependencies are
# installed separately by build.mjs with --os=win32 --cpu=x64.
RUN npm ci --no-audit --no-fund

# --allow-dirty: the build context has no .git, so the worktree check is skipped.
# The Go toolchain makes build.mjs produce Luminary.exe instead of the .cmd/.vbs
# pair; pass --launcher ps to force the PowerShell-only launcher.
RUN node windows/build.mjs --out /out --allow-dirty

FROM scratch AS artifacts
COPY --from=build /out/ /
