Use docker compose in build

This commit is contained in:
Gabriel Augendre 2020-08-21 14:32:01 +02:00
parent fc5ac92685
commit 2dbe8bf16e
4 changed files with 18 additions and 11 deletions

View file

@ -1,6 +1,7 @@
image: archlinux image: archlinux
packages: packages:
- docker - docker
- docker-compose
sources: sources:
- https://git.sr.ht/~crocmagnon/blog - https://git.sr.ht/~crocmagnon/blog
secrets: secrets:
@ -13,12 +14,13 @@ tasks:
- setup_docker: | - setup_docker: |
./blog/docker/setup-docker ./blog/docker/setup-docker
- build_and_test: | - build_and_test: |
docker info
docker login -u crocmagnon --password-stdin < .docker-secret docker login -u crocmagnon --password-stdin < .docker-secret
docker pull crocmagnon/blog || true cd blog
docker build --cache-from crocmagnon/blog:latest -t crocmagnon/blog blog/ docker-compose pull django tests || true
docker run -t --rm crocmagnon/blog /app/docker/runtests.sh docker-compose build --pull django
docker push crocmagnon/blog docker-compose build tests
docker-compose run tests
docker-compose push django tests
- deploy: | - deploy: |
ssh blog -o StrictHostKeyChecking=no "/srv/blog/redeploy" ssh blog -o StrictHostKeyChecking=no "/srv/blog/redeploy"
triggers: triggers:

View file

@ -1,7 +1,7 @@
version: '2.4' version: '2.4'
services: services:
django: django:
image: crocmagnon/blog image: crocmagnon/blog:latest
build: . build: .
ports: ports:
- 8000:8000 - 8000:8000
@ -12,7 +12,7 @@ services:
- ./static:/app/staticfiles - ./static:/app/staticfiles
restart: on-failure restart: on-failure
tests: tests:
image: crocmagnon/blog image: crocmagnon/blog:tests
build: . build:
command: ["/app/docker/runtests.sh"] context: .
healthcheck: {} dockerfile: tests.Dockerfile

View file

@ -1,3 +1,2 @@
#!/bin/sh #!/bin/sh
pip install -r /app/requirements-dev.txt --progress-bar off
TESTING=true python -m pytest TESTING=true python -m pytest

6
tests.Dockerfile Normal file
View file

@ -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"]