Skip to content

Commit

Permalink
fix(gh action): add docker-compose-test-runner for github action djan…
Browse files Browse the repository at this point in the history
…go_tests

Introduce a separate docker-compose file for use with the django_tests github
action that replicates the production run environment (use of gunicorn rather
than the django development server).
  • Loading branch information
dchiller committed Aug 6, 2024
1 parent e7cdd79 commit f0c1e4d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/django_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
envkey_AWS_EMAIL_HOST_PASSWORD: test_password
directory: config/envs
file_name: dev_env
- run: docker compose -f docker-compose-development.yml build
- run: docker compose -f docker-compose-development.yml up -d
- run: docker compose -f docker-compose-development.yml exec -T django python manage.py test main_app.tests
- run: docker compose -f docker-compose-test-runner.yml build
- run: docker compose -f docker-compose-test-runner.yml up -d
- run: docker compose -f docker-compose-test-runner.yml exec -T django python manage.py test main_app.tests
64 changes: 64 additions & 0 deletions docker-compose-test-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file is configured for deployment of the CantusDB project on the GitHub action
# test runner. The GitHub action is configured to use this compose file.

services:
django:
build:
context: .
dockerfile: ./django/Dockerfile
args:
PROJECT_ENVIRONMENT: DEVELOPMENT
container_name: cantusdb-django-1
volumes:
- ./django/cantusdb_project:/code/cantusdb_project
- static_volume:/resources/static
- media_volume:/resources/media
- api_cache_volume:/resources/api_cache
env_file: ./config/envs/dev_env
restart: always
depends_on:
- postgres
command:
[
"gunicorn",
"--bind",
":8000",
"cantusdb.wsgi:application",
"--workers",
"5"
]

nginx:
build:
context: ./nginx
ports:
- 80:80
- 443:443
container_name: cantusdb-nginx-1
volumes:
- ./config/nginx/conf.d:/etc/nginx/conf.d
- static_volume:/resources/static
- media_volume:/resources/media
- api_cache_volume:/resources/api_cache
- ./certificates:/etc/nginx/ssl/live
restart: always
depends_on:
- django

postgres:
build:
context: ./postgres
env_file: ./config/envs/dev_env
ports:
- 5432:5432
container_name: cantusdb-postgres-1
volumes:
- postgres_data:/var/lib/postgresql/data/
restart: always
command: postgres -c 'config_file=/etc/postgresql/postgresql.conf'

volumes:
postgres_data:
static_volume:
media_volume:
api_cache_volume:

0 comments on commit f0c1e4d

Please sign in to comment.