# Builds the radicle-explorer SPA and serves the static output with nginx.
#
# radicle-explorer ships no image and is a rolling release, so we clone it at a
# pinned ref and build with VITE_RUNTIME_CONFIG=true. That makes the bundle load
# /config.json from the server at runtime (mounted by the recipe as a Swarm
# config), so this image is generic and does not bake in a seed address.
#
# Build:
#   docker build \
#     --build-arg EXPLORER_REF=<commit-sha> \
#     -t git.coopcloud.tech/c4dt/radicle-explorer:<tag> build/explorer
FROM node:24-alpine AS build

ARG EXPLORER_REPO=https://github.com/radicle-dev/radicle-explorer.git
# Pin to the commit the recipe was tested against (bump with the image tag).
ARG EXPLORER_REF=master

RUN apk add --no-cache git
WORKDIR /app
RUN git clone "$EXPLORER_REPO" . \
    && git checkout "$EXPLORER_REF"

RUN npm ci
RUN VITE_RUNTIME_CONFIG=true npm run build

FROM nginx:alpine
# The recipe overrides this default.conf with its own (adds the /api/v1 proxy).
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
