diff --git a/Dockerfile b/Dockerfile index 785b618..23d2301 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ############################################## # Build virtualenv ############################################## -FROM python:3.10.1-buster AS venv +FROM python:3.10.2-buster AS venv # Prepare system ############################################## @@ -47,9 +47,9 @@ RUN git rev-parse HEAD | tee /version ############################################## # Main image ############################################## -FROM python:3.10.1-slim-buster as prod +FROM python:3.10.2-slim-buster as prod -RUN echo "Europe/Paris" > /etc/timezone +ENV TZ="Europe/Paris" COPY --from=venv /app/venv /app/venv/ ENV PATH /app/venv/bin:$PATH diff --git a/docker-compose-build.yaml b/docker-compose-build.yaml new file mode 100644 index 0000000..727c85a --- /dev/null +++ b/docker-compose-build.yaml @@ -0,0 +1,11 @@ +version: '2.4' +services: + django: + extends: + file: docker-compose.yaml + service: django + image: rg.fr-par.scw.cloud/crocmagnon/shortener:latest + platform: linux/amd64 + +volumes: + shortener_data: diff --git a/docker-compose.yaml b/docker-compose.yaml index b132464..5360dbd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: "2.4" services: django: - image: rg.fr-par.scw.cloud/crocmagnon/shortener + image: shortener-dev build: . env_file: envs/docker.env ports: diff --git a/tasks.py b/tasks.py index bbc2a13..180d946 100644 --- a/tasks.py +++ b/tasks.py @@ -16,6 +16,8 @@ from invoke import Context, task BASE_DIR = Path(__file__).parent.resolve(strict=True) SRC_DIR = BASE_DIR / "src" +COMPOSE_BUILD_FILE = BASE_DIR / "docker-compose-build.yaml" +COMPOSE_BUILD_ENV = {"COMPOSE_FILE": COMPOSE_BUILD_FILE} @task @@ -28,7 +30,7 @@ def test(ctx: Context) -> None: def test_cov(ctx: Context) -> None: with ctx.cd(SRC_DIR): ctx.run( - "pytest --cov=. --cov-report term-missing:skip-covered", + "pytest --cov=. --cov-branch --cov-report term-missing:skip-covered", pty=True, echo=True, ) @@ -48,13 +50,17 @@ def check(ctx: Context) -> None: @task def build(ctx: Context) -> None: with ctx.cd(BASE_DIR): - ctx.run("docker-compose build django", pty=True, echo=True) + ctx.run( + "docker-compose build django", pty=True, echo=True, env=COMPOSE_BUILD_ENV + ) @task def publish(ctx: Context) -> None: with ctx.cd(BASE_DIR): - ctx.run("docker-compose push django", pty=True, echo=True) + ctx.run( + "docker-compose push django", pty=True, echo=True, env=COMPOSE_BUILD_ENV + ) @task