From 676180ac8010d13370620a4889fb07ae6122a335 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 27 Jun 2024 19:49:49 +0200 Subject: [PATCH] some tests, and docker fix --- Dockerfile | 7 +++++++ Makefile | 13 +++++++++++++ docker-compose.yml | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 70bd4f0..06bcb83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,18 @@ FROM python:3.10-alpine AS base +RUN apk update && apk add --no-cache \ + openssh-keygen COPY requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt WORKDIR /app/src +FROM base AS dev + +RUN pip install --no-cache-dir coverage + + FROM base AS prod RUN pip install --no-cache-dir gunicorn psycopg2-binary diff --git a/Makefile b/Makefile index b700ee6..9c0f292 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,20 @@ .PHONY: deploy +UID != id -u +GID != id -g + deploy: src/cas/localsettings.py pip install -r requirements.txt src/manage.py migrate --noinput src/manage.py collectstatic --noinput + +test: + rm -r htmlcov & + docker-compose run --rm dev sh -c '\ + coverage run --branch --source='.' --data-file ../.coverage ./manage.py test; \ + coverage html --data-file ../.coverage -d htmlcov; \ + coverage report --data-file ../.coverage; \ + chown -R $(UID):$(GID) htmlcov' + mv -f src/htmlcov . + diff --git a/docker-compose.yml b/docker-compose.yml index b1d9818..249139d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: dev: build: context: . - target: base + target: dev volumes: - ./src:/app/src - ./media:/app/media -- 2.20.1