From 2910ea7e63d5787fbaf673acbc04efc979146d5b Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Wed, 9 Feb 2022 12:24:13 +0100 Subject: [PATCH] split dockerfile --- Dockerfile | 38 ++++++++++++-------------------------- Dockerfile-base | 29 +++++++++++++++++++++++++++++ setup/docker.sh | 3 ++- setup/docker_local.sh | 8 -------- 4 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 Dockerfile-base delete mode 100755 setup/docker_local.sh diff --git a/Dockerfile b/Dockerfile index 04c159b..ce41849 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,21 @@ -FROM python:3.8 as builder1 +ARG BASE_ROOT="nexus.iqser.com:5001/red/" +ARG VERSION_TAG=latest -# 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 . ./ - -# Set up service as a module and install all its dependencies. -RUN bash setup/docker_local.sh - -# 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" +FROM ${BASE_ROOT}detr-server-base:${VERSION_TAG} WORKDIR /app/service -RUN apt update --yes -RUN apt install vim --yes -RUN apt install poppler-utils --yes +COPY ./src ./src +COPY ./incl/detr ./incl/detr +COPY ./fb_detr ./fb_detr + +RUN python3 -m pip install -e . + +WORKDIR /app/service/incl/detr +RUN python3 -m pip install -e . +WORKDIR /app/service EXPOSE 5000 EXPOSE 8080 -# Run the service loop. CMD ["python3", "src/run_service.py"] diff --git a/Dockerfile-base b/Dockerfile-base new file mode 100644 index 0000000..d2a91c1 --- /dev/null +++ b/Dockerfile-base @@ -0,0 +1,29 @@ +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 . ./ + +# 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 + +RUN apt update --yes +RUN apt install vim --yes +RUN apt install poppler-utils --yes diff --git a/setup/docker.sh b/setup/docker.sh index 537d3d3..5f8b0a1 100755 --- a/setup/docker.sh +++ b/setup/docker.sh @@ -11,4 +11,5 @@ dvc pull git submodule update --init --recursive -docker build -t detr-server . +docker build -f Dockerfile-base -t detr-server-base . +docker build -f Dockerfile -t detr-server . --build-arg VERSION_TAG=latest diff --git a/setup/docker_local.sh b/setup/docker_local.sh deleted file mode 100755 index 1b951d1..0000000 --- a/setup/docker_local.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -e - -pip install -e . -pip install -r requirements.txt - -cd incl/detr -pip install -e .