-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (57 loc) · 2.4 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CI/CD for Django with Docker Compose
on:
push:
branches: [ "deployment" ]
jobs:
build-test-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
logout: true
- name: Create docker.env File
run: |
echo "DJANGO_SECRET_KEY=test_secret_key" >> docker.env
echo "DB_HOST=db" >> docker.env
echo "DJANGO_DEBUG=False" >> docker.env
echo "POSTGRES_DB=vis_phewas_db" >> docker.env
echo "DB_NAME=vis_phewas_db" >> docker.env
echo "POSTGRES_PASSWORD=default_secure_password" >> docker.env
echo "DB_PASS=default_secure_password" >> docker.env
echo "DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1" >> docker.env
echo "POSTGRES_USER=postgres" >> docker.env
echo "DB_USER=postgres" >> docker.env
cat docker.env
- name: Build and Run with Docker Compose
run: |
docker compose --env-file docker.env -f docker-compose-build.yml up -d --build
- name: Health Check
run: |
sleep 10 # Give the containers some time to start
curl --fail http://localhost:8000 || (docker compose -f docker-compose-build.yml logs web && \
docker compose -f docker-compose-build.yml exec web cat /app/vis_phewas/debug.log && exit 1)
- name: Wait for DB to Start
run: |
sleep 20 # Give the DB some time to start
docker compose -f docker-compose-build.yml logs db
docker compose -f docker-compose-build.yml exec -T db pg_isready -U postgres
- name: Run Integration Tests
run: |
docker compose -f docker-compose-build.yml exec -T web python manage.py test
- name: Stop and Remove Containers
run: |
docker compose -f docker-compose-build.yml down
- name: Tag and Push Web Image to Docker Hub
run: |
docker tag vis-phewas-web tnaccarato/vis-phewas:web
docker push tnaccarato/vis-phewas:web
- name: Tag and Push DB Image to Docker Hub
run: |
docker tag vis-phewas-db tnaccarato/vis-phewas:db
docker push tnaccarato/vis-phewas:db