FROM nginx:1.27-alpine

RUN apk add --no-cache python3 supervisor && \
    python3 -m venv /app/venv && \
    /app/venv/bin/pip install --no-cache-dir flask

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisord.conf
COPY api.py /app/api.py
COPY site/ /usr/share/nginx/html/

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
  CMD wget -q -O /dev/null http://127.0.0.1:8000/ || exit 1

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
