From 2dbe8bf16e6eaeaa51e9c61ec3b74d3e5304d69b Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 21 Aug 2020 14:32:01 +0200 Subject: [PATCH] Use docker compose in build --- .build.yml | 12 +++++++----- docker-compose.yml | 10 +++++----- docker/runtests.sh | 1 - tests.Dockerfile | 6 ++++++ 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 tests.Dockerfile diff --git a/.build.yml b/.build.yml index cb5ca6a..a0f189c 100644 --- a/.build.yml +++ b/.build.yml @@ -1,6 +1,7 @@ image: archlinux packages: - docker + - docker-compose sources: - https://git.sr.ht/~crocmagnon/blog secrets: @@ -13,12 +14,13 @@ tasks: - setup_docker: | ./blog/docker/setup-docker - build_and_test: | - docker info docker login -u crocmagnon --password-stdin < .docker-secret - docker pull crocmagnon/blog || true - docker build --cache-from crocmagnon/blog:latest -t crocmagnon/blog blog/ - docker run -t --rm crocmagnon/blog /app/docker/runtests.sh - docker push crocmagnon/blog + cd blog + docker-compose pull django tests || true + docker-compose build --pull django + docker-compose build tests + docker-compose run tests + docker-compose push django tests - deploy: | ssh blog -o StrictHostKeyChecking=no "/srv/blog/redeploy" triggers: diff --git a/docker-compose.yml b/docker-compose.yml index 42ea2c7..772b1b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2.4' services: django: - image: crocmagnon/blog + image: crocmagnon/blog:latest build: . ports: - 8000:8000 @@ -12,7 +12,7 @@ services: - ./static:/app/staticfiles restart: on-failure tests: - image: crocmagnon/blog - build: . - command: ["/app/docker/runtests.sh"] - healthcheck: {} + image: crocmagnon/blog:tests + build: + context: . + dockerfile: tests.Dockerfile diff --git a/docker/runtests.sh b/docker/runtests.sh index 9b43ca5..a22b9ed 100755 --- a/docker/runtests.sh +++ b/docker/runtests.sh @@ -1,3 +1,2 @@ #!/bin/sh -pip install -r /app/requirements-dev.txt --progress-bar off TESTING=true python -m pytest diff --git a/tests.Dockerfile b/tests.Dockerfile new file mode 100644 index 0000000..f4a909f --- /dev/null +++ b/tests.Dockerfile @@ -0,0 +1,6 @@ +FROM crocmagnon/blog +RUN pip install -r requirements-dev.txt +ENV TESTING "true" +WORKDIR /app +HEALTHCHECK none +CMD ["python", "-m", "pytest"]