FROM docker.io/library/nginx:alpine

RUN rm /etc/nginx/conf.d/default.conf && \
    apk add --no-cache coreutils

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY src/ /src/
COPY build.sh /build.sh
RUN chmod +x /build.sh && SRC=/src DIST=/dist /bin/sh /build.sh && cp -r /dist/* /usr/share/nginx/html/ && rm -rf /src /build.sh /dist

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -qO- http://localhost:8080/ || exit 1