update dockerfile to work with poetry

This commit is contained in:
francisco.schulz 2023-06-07 12:52:52 +02:00
parent 44dd613715
commit 79163c33cf

View File

@ -1,27 +1,39 @@
FROM python:3.8
RUN python -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
ARG USERNAME
ARG TOKEN
ARG PYPI_REGISTRY_RESEARCH=https://gitlab.knecon.com/api/v4/groups/19/-/packages/pypi
ARG POETRY_SOURCE_REF_RESEARCH=gitlab-research
ARG PYPI_REGISTRY_RED=https://gitlab.knecon.com/api/v4/groups/12/-/packages/pypi
ARG POETRY_SOURCE_REF_RED=gitlab-red
ARG VERSION=dev
RUN python -m pip install --upgrade pip
LABEL maintainer="Research <research@knecon.com>"
LABEL version="${VERSION}"
WORKDIR /app/service
WORKDIR /app
COPY ./requirements.txt ./requirements.txt
RUN python3 -m pip install -r requirements.txt
ENV PYTHONUNBUFFERED=true
ENV POETRY_HOME=/opt/poetry
ENV PATH="$POETRY_HOME/bin:$PATH"
COPY ./incl/pdf2image/requirements.txt ./incl/pdf2image/requirements.txt
RUN python -m pip install -r incl/pdf2image/requirements.txt
RUN curl -sSL https://install.python-poetry.org | python3 -
COPY ./incl ./incl
COPY ./data ./data
COPY pyproject.toml poetry.lock ./src ./cv_analysis ./
RUN python3 -m pip install incl/pyinfra
RUN python3 -m pip install -e incl/pdf2image
RUN ls -hal
RUN echo "${USERNAME} ${TOKEN} ${PYPI_REGISTRY_RED} ${POETRY_SOURCE_REF_RED} "
COPY ./src ./src
COPY ./cv_analysis ./cv_analysis
COPY ./setup.py ./setup.py
RUN poetry config virtualenvs.create false && \
poetry config installer.max-workers 10 && \
poetry config repositories.${POETRY_SOURCE_REF_RESEARCH} ${PYPI_REGISTRY_RESEARCH} && \
poetry config http-basic.${POETRY_SOURCE_REF_RESEARCH} ${USERNAME} ${TOKEN} && \
poetry config repositories.${POETRY_SOURCE_REF_RED} ${PYPI_REGISTRY_RED} && \
poetry config http-basic.${POETRY_SOURCE_REF_RED} ${USERNAME} ${TOKEN} && \
poetry install --without=test -vv --no-interaction --no-root
RUN python3 -m pip install -e .
EXPOSE 5000
EXPOSE 8080
CMD ["python3", "-u", "src/serve.py"]
CMD [ "python", "serve.py"]