From 2f5022baf82578e5133d9d8e9bb41f7525fe1b0b Mon Sep 17 00:00:00 2001 From: Aditya Ghyar Date: Thu, 9 Jul 2026 01:23:23 +0530 Subject: [PATCH] build: separate test and runtime Dockerfiles --- .dockerignore | 3 ++- Dockerfile | 4 +++- Dockerfile.test | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.test diff --git a/.dockerignore b/.dockerignore index 76bfd39..1d5e5ef 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,4 +8,5 @@ htmlcov .coverage .env docs -*.pyc \ No newline at end of file +*.pyc +!tests/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a6bbfa5..ea79268 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir --prefix=/install -r requirements.txt +COPY app ./app + FROM python:3.12.10-slim-bookworm RUN useradd -m app @@ -18,4 +20,4 @@ USER app EXPOSE 8000 -CMD ["uvicorn","app.main:app","--host","0.0.0.0","--port","8000"] \ No newline at end of file +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..cf76478 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,15 @@ +FROM python:3.12.10-slim-bookworm + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app ./app +COPY tests ./tests +COPY pytest.ini* ./ +ENV DATABASE_URL=sqlite:///./test.db \ + APP_PORT=8000 \ + LOG_LEVEL=INFO + +RUN python -m pytest -v \ No newline at end of file