From 55c9f3db9c5aac392bb4415111fb0c1e0d97209a Mon Sep 17 00:00:00 2001 From: rchan Date: Thu, 13 Jun 2024 08:06:51 +0100 Subject: [PATCH] hopefully smaller and faster docker builds --- docker/create_index/Dockerfile | 18 +++++++++++++----- docker/reginald_app/Dockerfile | 16 ++++++++++++---- docker/run_all/Dockerfile | 16 ++++++++++++---- docker/slack_bot/Dockerfile | 16 ++++++++++++---- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/docker/create_index/Dockerfile b/docker/create_index/Dockerfile index 8144f91..0840e7e 100644 --- a/docker/create_index/Dockerfile +++ b/docker/create_index/Dockerfile @@ -1,14 +1,22 @@ -FROM python:3.11.4 +FROM python:3.11.9 WORKDIR /app # Setup Python prerequisites -RUN pip3 install --upgrade pip poetry setuptools wheel +RUN pip3 install --upgrade pip poetry==1.8.3 setuptools wheel + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache # Build Python project -COPY reginald reginald COPY pyproject.toml . -COPY README.md . -RUN poetry install +RUN touch README.md +RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR + +COPY reginald reginald + +RUN poetry install --without dev CMD ["poetry", "run", "reginald", "create-index"] diff --git a/docker/reginald_app/Dockerfile b/docker/reginald_app/Dockerfile index 05fd4d1..097e58b 100644 --- a/docker/reginald_app/Dockerfile +++ b/docker/reginald_app/Dockerfile @@ -1,14 +1,22 @@ -FROM python:3.11.4 +FROM python:3.11.9 WORKDIR /app # Setup Python prerequisites RUN pip3 install --upgrade pip poetry setuptools wheel +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + # Build Python project -COPY reginald reginald COPY pyproject.toml . -COPY README.md . -RUN poetry install --extras api_bot +RUN touch README.md +RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR + +COPY reginald reginald + +RUN poetry install --extras api_bot --without dev CMD ["poetry", "run", "reginald", "app"] diff --git a/docker/run_all/Dockerfile b/docker/run_all/Dockerfile index e36cb31..0bdeaf0 100644 --- a/docker/run_all/Dockerfile +++ b/docker/run_all/Dockerfile @@ -1,14 +1,22 @@ -FROM python:3.11.4 +FROM python:3.11.9 WORKDIR /app # Setup Python prerequisites RUN pip3 install --upgrade pip poetry setuptools wheel +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + # Build Python project -COPY reginald reginald COPY pyproject.toml . -COPY README.md . -RUN poetry install +RUN touch README.md +RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR + +COPY reginald reginald + +RUN poetry install --without dev CMD ["poetry", "run", "reginald", "run-all"] diff --git a/docker/slack_bot/Dockerfile b/docker/slack_bot/Dockerfile index 917e969..05c0730 100644 --- a/docker/slack_bot/Dockerfile +++ b/docker/slack_bot/Dockerfile @@ -1,14 +1,22 @@ -FROM python:3.11.4 +FROM python:3.11.9 WORKDIR /app # Setup Python prerequisites RUN pip3 install --upgrade pip poetry setuptools wheel +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + # Build Python project -COPY reginald reginald COPY pyproject.toml . -COPY README.md . -RUN poetry install --extras api_bot +RUN touch README.md +RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR + +COPY reginald reginald + +RUN poetry install --extras api_bot --without dev CMD ["poetry", "run", "reginald", "bot"]