From 7fbdd0606ce81ba43d0e07c5541d56e47450cd3a Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 28 May 2023 12:40:10 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Reduce=20the=20size=20of?= =?UTF-8?q?=20the=20backend=20docker=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/.dockerignore | 15 ++++++++++----- backend/Dockerfile | 14 +++++++++++--- backend/pyproject.toml | 1 - 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/backend/.dockerignore b/backend/.dockerignore index 714e0da..78a50e3 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -1,7 +1,12 @@ -docker +.dir-locals.el +.dockerignore +.gitignore +**/.mypy_cache +**/.ruff_cache +.venv **/__pycache__ -poetry.lock -Dockerfile -docker-compose.yml config -.venv \ No newline at end of file +docker +poetry.lock +tests +Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile index a11f9ec..06c6fe6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,9 +1,13 @@ FROM python:3.11-slim as builder WORKDIR /app -COPY . /app -RUN apt update && apt install -y proj-bin +COPY ./pyproject.toml /app + +RUN apt update && \ + apt install -y --no-install-recommends proj-bin && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* RUN pip install --upgrade poetry && \ poetry config virtualenvs.create false && \ @@ -15,7 +19,11 @@ FROM python:3.11-slim as runtime COPY . /app COPY --from=builder /app/requirements.txt /app -RUN apt update && apt install -y postgresql libpq5 +RUN apt update && \ + apt install -y --no-install-recommends postgresql libpq5 && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + RUN pip install --no-cache-dir -r /app/requirements.txt WORKDIR /app diff --git a/backend/pyproject.toml b/backend/pyproject.toml index e104d15..57c7872 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "" authors = ["Adrien SUEUR "] readme = "README.md" -packages = [{include = "backend"}] [tool.poetry.dependencies] python = "^3.11"