FROM hugomods/hugo:exts AS builder

WORKDIR /src
COPY . .

RUN hugo -d public -b https://adriano.fyi

FROM alpine:latest

RUN apk update && apk add --no-cache nginx && \
    adduser -D static

RUN mkdir -p /var/lib/nginx/tmp/client_body && \
    chown -R static:static /var/lib/nginx /home/static && \
    chmod -R 755 /home/static

WORKDIR /home/static

COPY --from=builder /src/nginx.conf /home/static/nginx.conf

COPY --from=builder --chown=static:static /src/public /home/static/public

USER static
EXPOSE 3000

ENTRYPOINT ["nginx", "-e", "/dev/stderr", "-c", "/home/static/nginx.conf"]
