FROM alpine:3.21 AS builder

RUN apk add --no-cache bash yq coreutils findutils

WORKDIR /src
COPY . .

RUN chmod +x build.sh render.sh generate-caddyfile.sh && \
    ./build.sh

FROM caddy:alpine

COPY --from=builder /src/build/ /srv/
COPY --from=builder /src/Caddyfile /etc/caddy/Caddyfile

RUN caddy validate --config /etc/caddy/Caddyfile
EXPOSE 80
