Skip to content

Commit

Permalink
Update docker compose (#256)
Browse files Browse the repository at this point in the history
* Fix min_qg_version query in plugins.xml (#224)

* fix min_qg_version query

* added 0 patch value for qgis version against max_qg_version

* only add patch if it has major.minor version

* Update docker-compose and dockerfile

* Update nginx configuration

* Update smtp

* Add celery beat

* Add feedjack update celery task

* Add metabase configuration

* Update test.yaml

* Add test docker-compose

Co-authored-by: sumandari <[email protected]>
  • Loading branch information
dimasciput and sumandari authored Aug 21, 2022
1 parent f7a37c6 commit d4c8550
Show file tree
Hide file tree
Showing 18 changed files with 423 additions and 150 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dockerize/postgres_data
16 changes: 11 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,29 @@ jobs:
- uses: actions/checkout@v2

- name: Run docker-compose build
run: docker-compose build
run: docker-compose build devweb

- name: Run the containers
run: docker-compose up -d db devweb
- name: Run docker-compose services
working-directory: dockerize
run: |
cp docker-compose.override.test.yml docker-compose.override.yml
make devweb-test
make wait-db
make create-test-db
- name: Run Coverage test
run: |
cat << EOF | docker-compose exec -T devweb bash
cat << EOF | docker-compose -p qgis-plugins exec -T devweb bash
pip install coverage
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic --noinput --verbosity 0
coverage run manage.py test
coverage xml
EOF
- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ qgis-app/api/tests/*/

# whoosh_index
qgis-app/whoosh_index/
docker-compose.override.yml
.env
6 changes: 6 additions & 0 deletions dockerize/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RABBITMQ_HOST=rabbitmq
DATABASE_NAME=gis
DATABASE_USERNAME=docker
DATABASE_PASSWORD=docker
DATABASE_HOST=db
DJANGO_SETTINGS_MODULE=settings_docker
46 changes: 44 additions & 2 deletions dockerize/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,47 @@ build:
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) build

build-dev:
@echo
@echo "------------------------------------------------------------------"
@echo "Building in development mode only"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) build devweb

db:
@echo
@echo "------------------------------------------------------------------"
@echo "Running db in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) up -d db

metabase: db
@echo
@echo "------------------------------------------------------------------"
@echo "Running metabase in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) up -d metabase

web: db
@echo
@echo "------------------------------------------------------------------"
@echo "Running in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) up -d web
@docker-compose -p $(PROJECT_ID) up -d uwsgi web smtp worker beat

devweb-test: db
@echo
@echo "------------------------------------------------------------------"
@echo "Running in TESTING mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) up --no-deps -d devweb

devweb: db
@echo
@echo "------------------------------------------------------------------"
@echo "Running in DEVELOPMENT mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) up --no-deps -d devweb
@docker-compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat

devweb-runserver: devweb
@echo
Expand Down Expand Up @@ -100,6 +121,20 @@ rm-only: kill
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) rm

maillogs:
@echo
@echo "------------------------------------------------------------------"
@echo "Showing smtp logs in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec smtp tail -f /var/log/mail.log

mailerrorlogs:
@echo
@echo "------------------------------------------------------------------"
@echo "Showing smtp error logs in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec smtp tail -f /var/log/mail.err

dbrestore:
@echo
@echo "------------------------------------------------------------------"
Expand All @@ -119,3 +154,10 @@ dbrestore:
@docker exec -t $(PROJECT_ID)-db pg_restore /backups/latest.dmp | docker exec -i $(PROJECT_ID)-db su - postgres -c "psql gis"
@docker-compose -p $(PROJECT_ID) start web
@echo "starting web container"

wait-db:
@docker-compose exec -p $(PROJECT_ID) db su - postgres -c "until pg_isready; do sleep 5; done"

create-test-db:
@docker-compose exec -p $(PROJECT_ID) db su - postgres -c "psql -c 'create database test_db;'"
@docker-compose exec -p $(PROJECT_ID) db su - postgres -c "psql -d test_db -c 'create extension postgis;'"
55 changes: 55 additions & 0 deletions dockerize/docker-compose.override.template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'
services:
devweb:
# Note you cannot scale if you use container_name
image: kartoza/qgis-plugins-uwsgi:dev-latest
container_name: qgis-plugins-devweb
volumes:
- ../qgis-app:/home/web/django_project
- ./static:/home/web/static:rw
- ./media:/home/web/media:rw
build:
context: ${PWD}/../
dockerfile: dockerize/docker/Dockerfile
target: dev
ports:
# for django test server
- "62202:8080"
# for ssh
- "62203:22"

beat:
volumes:
- ../qgis-app:/home/web/django_project
- ./static:/home/web/static:rw
- ./media:/home/web/media:rw

worker:
volumes:
- ../qgis-app:/home/web/django_project
- ./static:/home/web/static:rw
- ./media:/home/web/media:rw

uwsgi:
container_name: qgis-plugins-uwsgi
volumes:
- ../qgis-app:/home/web/django_project
- ./static:/home/web/static:rw
- ./media:/home/web/media:rw
build:
context: ${PWD}/../
dockerfile: dockerize/docker/Dockerfile
target: prod

db:
volumes:
- ./postgres_data:/var/lib/postgresql
- ./backups:/backups

web:
volumes:
- ./sites-enabled:/etc/nginx/conf.d:ro
- ./static:/home/web/static:ro
- ./media:/home/web/media:ro
ports:
- "62201:8080"
19 changes: 19 additions & 0 deletions dockerize/docker-compose.override.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3'
services:
devweb:
# Note you cannot scale if you use container_name
image: kartoza/qgis-plugins-uwsgi:dev-latest
container_name: qgis-plugins-devweb
volumes:
- ../qgis-app:/home/web/django_project
- ./static:/home/web/static:rw
- ./media:/home/web/media:rw
build:
context: ${PWD}/../
dockerfile: dockerize/docker/Dockerfile
target: dev
ports:
# for django test server
- "62202:8080"
# for ssh
- "62203:22"
Loading

0 comments on commit d4c8550

Please sign in to comment.