FROM node:22-alpine AS engine
WORKDIR /gpu
COPY gpu-bg/package.json gpu-bg/package-lock.json* ./
RUN npm ci
COPY gpu-bg/ ./
RUN npm run build

# hugomods/hugo is the maintained successor to the deprecated klakegg/hugo image.
# The "dart-sass" variant is extended Hugo + dart-sass (required: hugo-coder compiles
# SCSS via toCSS, and Hugo 0.129+ dropped libsass in favor of dart-sass).
FROM hugomods/hugo:debian-dart-sass-go-0.165.0 AS site
WORKDIR /site
COPY . .
COPY --from=engine /gpu/dist ./static/gpu/
RUN hugo --minify

FROM nginx:alpine-slim AS serve
RUN apk add --no-cache curl
COPY --from=site /site/public /usr/share/nginx/html
RUN rm -f /etc/nginx/conf.d/default.conf
COPY nginx.default.conf /etc/nginx/conf.d/default.conf
RUN nginx -t
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]