From 7b37f3c9138731550666b01d0ecf22c94b522f24 Mon Sep 17 00:00:00 2001 From: "francisco.schulz" Date: Wed, 7 Jun 2023 17:41:54 +0200 Subject: [PATCH] update Dockerfiles --- Dockerfile | 43 ++++++++++++++++++++++++++++--------------- Dockerfile_base | 25 ------------------------- Dockerfile_tests | 45 +++++++++++++++++++++++++++++---------------- 3 files changed, 57 insertions(+), 56 deletions(-) delete mode 100644 Dockerfile_base diff --git a/Dockerfile b/Dockerfile index 66d472e..67c4038 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,36 @@ -FROM image-prediction-base +FROM python:3.8 -WORKDIR /app/service +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 -COPY src src -COPY incl/pyinfra incl/pyinfra -COPY data data -COPY image_prediction image_prediction -COPY setup.py setup.py -COPY requirements.txt requirements.txt -COPY config.yaml config.yaml -COPY banner.txt banner.txt +LABEL maintainer="Research " +LABEL version="${VERSION}" -# Install dependencies differing from base image. -RUN python3 -m pip install -r requirements.txt +WORKDIR /app -RUN python3 -m pip install -e . -RUN python3 -m pip install incl/pyinfra +ENV PYTHONUNBUFFERED=true +ENV POETRY_HOME=/opt/poetry +ENV PATH="$POETRY_HOME/bin:$PATH" + +RUN curl -sSL https://install.python-poetry.org | python3 - + +COPY ./data ./data +COPY pyproject.toml poetry.lock banner.txt config.yaml ./src ./image_prediction ./ + +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 EXPOSE 5000 EXPOSE 8080 -CMD ["python3", "src/serve.py"] +CMD [ "python", "serve.py"] diff --git a/Dockerfile_base b/Dockerfile_base deleted file mode 100644 index c4164e0..0000000 --- a/Dockerfile_base +++ /dev/null @@ -1,25 +0,0 @@ -FROM python:3.8 as builder1 - -# Use a virtual environment. -RUN python -m venv /app/venv -ENV PATH="/app/venv/bin:$PATH" - -# Upgrade pip. -RUN python -m pip install --upgrade pip - -# Make a directory for the service files and copy the service repo into the container. -WORKDIR /app/service -COPY ./requirements.txt ./requirements.txt - -# Install dependencies. -RUN python3 -m pip install -r requirements.txt - -# Make a new container and copy all relevant files over to filter out temporary files -# produced during setup to reduce the final container's size. -FROM python:3.8 - -WORKDIR /app/ -COPY --from=builder1 /app . -ENV PATH="/app/venv/bin:$PATH" - -WORKDIR /app/service diff --git a/Dockerfile_tests b/Dockerfile_tests index 831f8c6..28247b7 100644 --- a/Dockerfile_tests +++ b/Dockerfile_tests @@ -1,24 +1,37 @@ -ARG BASE_ROOT="nexus.iqser.com:5001/red/" -ARG VERSION_TAG="dev" +FROM python:3.8 -FROM ${BASE_ROOT}image-prediction:${VERSION_TAG} +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 -WORKDIR /app/service +LABEL maintainer="Research " +LABEL version="${VERSION}" -COPY src src -COPY incl/pyinfra incl/pyinfra -COPY data data -COPY image_prediction image_prediction -COPY setup.py setup.py -COPY requirements.txt requirements.txt -COPY config.yaml config.yaml -COPY banner.txt banner.txt +WORKDIR /app -# Install module & dependencies -RUN python3 -m pip install -r requirements.txt +ENV PYTHONUNBUFFERED=true +ENV POETRY_HOME=/opt/poetry +ENV PATH="$POETRY_HOME/bin:$PATH" -RUN python3 -m pip install -e . -RUN python3 -m pip install incl/pyinfra +RUN curl -sSL https://install.python-poetry.org | python3 - + +COPY ./data ./data +COPY pyproject.toml poetry.lock banner.txt config.yaml ./src ./image_prediction ./ + +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 + +EXPOSE 5000 +EXPOSE 8080 RUN apt update --yes RUN apt install vim --yes