FROM python:3.8-alpine as venv WORKDIR /opt/app RUN \ apk add --no-cache alpine-sdk=1.0-r1 cmake=3.26.5-r0 linux-headers=6.3-r0 \ libffi-dev=3.4.4-r2 \ && pip3 --no-cache-dir install poetry==1.7.1 COPY ./pyproject.toml . COPY ./poetry.lock . RUN \ poetry export --with=deployment --format requirements.txt \ --output requirements.txt \ && python -m venv /opt/app/venv \ && /opt/app/venv/bin/python -m pip install -r requirements.txt FROM python:3.8-alpine as builder WORKDIR /opt/build RUN \ apk add --no-cache alpine-sdk=1.0-r1 cmake=3.26.5-r0 linux-headers=6.3-r0 \ libffi-dev=3.4.4-r2 \ && pip3 --no-cache-dir install poetry==1.7.1 COPY ./pyproject.toml . COPY ./poetry.lock . RUN \ poetry export --with dev,docs --format requirements.txt \ --output requirements.txt \ && python -m venv /opt/build/venv \ && /opt/build/venv/bin/python -m pip install -r requirements.txt COPY ./docs ./docs COPY ./textoutpc ./textoutpc RUN /opt/build/venv/bin/sphinx-build -M html ./docs ./build COPY ./textoutpc ./textoutpc FROM python:3.8-alpine as app ENV PYTHONUNBUFFERED=1, PYTHONDONTWRITEBYTECODE=1 RUN addgroup -S app && adduser -S app app RUN apk add --no-cache supervisor=4.2.5-r2 nginx=1.24.0-r7 \ && chown -R app /var/lib/nginx/ /var/log/nginx/ /run/nginx/ \ && chgrp -R app /var/lib/nginx/ /var/log/nginx/ /run/nginx/ USER app COPY --chmod=644 ./docker/supervisord.conf /etc/supervisord.conf COPY --chmod=644 ./docker/nginx.conf /etc/nginx/nginx.conf WORKDIR /opt/app COPY --from=venv /opt/app/venv ./venv COPY --from=builder --chown=app:app /opt/build/textoutpc ./textoutpc COPY --from=builder /opt/build/build/html /opt/app/docs EXPOSE 80 ENTRYPOINT ["/usr/bin/supervisord"]