# The showcase site at quacklab.site.quack-lab.dev: gen.go writes the stylesheet and the site's pages, bun builds the
# behaviour script, nginx serves them. The changelog reads the version tags, and the build has no git, so task writes
# it into site/ before the build.
FROM golang:alpine AS pages

WORKDIR /src
COPY go.mod go.sum gen.go tokens.json components.css ./
COPY preview ./preview
COPY components ./components
RUN go run gen.go

FROM oven/bun:alpine AS script

WORKDIR /src
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production
COPY page.js quacklab.ts ./
RUN bun build page.js --format=iife --outfile=bundle.js

FROM nginx:alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=pages /src/site /usr/share/nginx/html
COPY --from=pages /src/quacklab.css /usr/share/nginx/html/
COPY --from=script /src/bundle.js /usr/share/nginx/html/
COPY fonts /usr/share/nginx/html/fonts
COPY site/changelog.html /usr/share/nginx/html/

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
