Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade project to Django 3/Python 3.7 #310

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 12 additions & 6 deletions REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
Django==2.2.25
Django==3.2.11

# Currently broken with 'no module named defaults' error
#Feedjack==0.9.18
# So use George's fork rather
# git+https://github.com/Erve1879/feedjack.git
# George's is also broken: use my fork (django 1.8 ready)
git+https://github.com/elpaso/feedjack.git
# George's is also broken: use elpaso fork (django 1.8 ready)
# git+https://github.com/elpaso/feedjack.git
# His is also broken, use dimasciput (django 3.2 ready)
git+https://github.com/dimasciput/feedjack.git

Markdown==2.3.1
#PIL==1.1.7
Pillow
Pygments==2.7.4

# Updates for Django 2 & Python 3.7
git+https://github.com/Xpirix/whoosh.git@a306553
git+https://github.com/Xpirix/whoosh.git@main
pickle5==0.0.12
django-haystack==3.2.1

Expand All @@ -21,16 +25,18 @@ argparse==1.2.1
django-annoying==0.7.7
django-auth-ldap==1.2.6
django-autoslug==1.7.1
django-debug-toolbar==1.11.1
django-debug-toolbar==3.2.4
django-endless-pagination==2.0
django-extensions==1.2.0
django-generic-aggregation==0.3.2
#django-olwidget==0.61.0 unmaintained, use this fork
git+https://github.com/Christophe31/olwidget.git
django-pagination==1.0.7

# Unmaintained!
#django-ratings==0.3.7
git+https://github.com/enikesha/django-ratings.git
git+https://github.com/gelo-zhukov/django-ratings.git

django-simple-ratings==0.3.2
# SIMPLEMENU
git+https://github.com/elpaso/django-simplemenu.git
Expand Down
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
59 changes: 51 additions & 8 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 All @@ -54,26 +75,26 @@ migrate:
@# We add the '-' prefix to the next line as the migration may fail
@# but we want to continue anyway.
@#We need to migrate accounts first as it has a reference to user model
-@docker-compose -p $(PROJECT_ID) exec web python manage.py migrate auth
@docker-compose -p $(PROJECT_ID) exec web python manage.py migrate
-@docker-compose -p $(PROJECT_ID) exec uwsgi python manage.py migrate auth
@docker-compose -p $(PROJECT_ID) exec uwsgi python manage.py migrate

update-migrations:
@echo
@echo "------------------------------------------------------------------"
@echo "Running update migrations in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) exec web python manage.py makemigrations
@docker-compose -p $(PROJECT_ID) exec uwsgi python manage.py makemigrations

collectstatic:
@echo
@echo "------------------------------------------------------------------"
@echo "Collecting static in production mode"
@echo "------------------------------------------------------------------"
#@docker-compose -p $(PROJECT_ID) run uwsgi python manage.py collectstatic --noinput
@docker-compose -p $(PROJECT_ID) run uwsgi python manage.py collectstatic --noinput
#We need to run collect static in the same context as the running
# uwsgi container it seems so I use docker exec here
# no -it flag so we can run over remote shell
@docker exec $(PROJECT_ID)-web python manage.py collectstatic --noinput
# @docker exec $(PROJECT_ID)-web python manage.py collectstatic --noinput

reload:
@echo
Expand All @@ -100,12 +121,27 @@ 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 "------------------------------------------------------------------"
@echo "Restore dump from backups/latest.dmp in production mode"
@echo "------------------------------------------------------------------"
@# - prefix causes command to continue even if it fails
@# - TODO: This command needs update since postgis has been updated.
@echo "stopping web container"
@docker-compose -p $(PROJECT_ID) stop web
@echo "dropping gis"
Expand All @@ -120,6 +156,13 @@ dbrestore:
@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;'"

dbseed:
@echo
@echo "------------------------------------------------------------------"
Expand All @@ -132,4 +175,4 @@ rebuild_index:
@echo "------------------------------------------------------------------"
@echo "Rebuild search index in PRODUCTION mode"
@echo "------------------------------------------------------------------"
@docker-compose -p $(PROJECT_ID) exec web bash -c 'python manage.py rebuild_index'
@docker-compose -p $(PROJECT_ID) exec uwsgi bash -c 'python manage.py rebuild_index'
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
Loading