From e0831ea5d27796c63139d88111b44048866a5f7b Mon Sep 17 00:00:00 2001 From: dimasciput Date: Thu, 20 Apr 2023 14:42:50 +0700 Subject: [PATCH] Add metabase, upgrade postgis --- .gitignore | 3 + REQUIREMENTS.txt | 1 + dockerize/.env.template | 6 + dockerize/Makefile | 4 +- dockerize/docker-compose.yml | 240 +++++++++++++++++++---------------- 5 files changed, 140 insertions(+), 114 deletions(-) create mode 100644 dockerize/.env.template diff --git a/.gitignore b/.gitignore index 4267cc6f..34ba9b58 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,9 @@ dockerize/media dockerize/logs .editorconfig +# dotenv +.env + # test cache qgis-app/*/tests/*/cache qgis-app/api/tests/*/ diff --git a/REQUIREMENTS.txt b/REQUIREMENTS.txt index 22a94caa..dedf22b8 100644 --- a/REQUIREMENTS.txt +++ b/REQUIREMENTS.txt @@ -39,6 +39,7 @@ feedparser==5.1.3 lxml==4.6.5 opml==0.5 psycopg2==2.5.1 +psycopg2-binary==2.8 python-ldap==2.4.19 # RPC4DJANGO git+https://github.com/davidfischer/rpc4django.git diff --git a/dockerize/.env.template b/dockerize/.env.template new file mode 100644 index 00000000..0dd30d9a --- /dev/null +++ b/dockerize/.env.template @@ -0,0 +1,6 @@ +DATABASE_NAME=gis +DATABASE_USERNAME=docker +DATABASE_PASSWORD=docker +DATABASE_HOST=db +DJANGO_SETTINGS_MODULE=settings_docker +RABBITMQ_HOST=rabbitmq diff --git a/dockerize/Makefile b/dockerize/Makefile index 21311379..6a8327df 100644 --- a/dockerize/Makefile +++ b/dockerize/Makefile @@ -111,12 +111,12 @@ dbrestore: @echo "dropping gis" @docker exec -t $(PROJECT_ID)-db su - postgres -c "dropdb gis" @echo "creating gis" - @docker exec -t $(PROJECT_ID)-db su - postgres -c "createdb -O docker -T template_postgis gis" + @docker exec -t $(PROJECT_ID)-db su - postgres -c "createdb -O docker gis" @echo "restoring gis" @# Because we pipe from one docker command to another and we are going @# to execute this Make command from a remote server at times, we need to using use interactive mode (-i) @# in the first command and not use terminal (-t) in the second. Please do not change these! - @docker exec -t $(PROJECT_ID)-db pg_restore /backups/latest.dmp | docker exec -i $(PROJECT_ID)-db su - postgres -c "psql gis" + @docker exec -t $(PROJECT_ID)-db pg_restore -d gis /backups/latest.dmp @docker-compose -p $(PROJECT_ID) start web @echo "starting web container" diff --git a/dockerize/docker-compose.yml b/dockerize/docker-compose.yml index 2ee672fb..f57015a3 100644 --- a/dockerize/docker-compose.yml +++ b/dockerize/docker-compose.yml @@ -1,117 +1,133 @@ -db: - container_name: qgis-plugins-db - image: kartoza/postgis:9.6-2.4 - environment: - - ALLOW_IP_RANGE=0.0.0.0/0 - - POSTGRES_USER=docker - - POSTGRES_PASS=docker - volumes: - - ./backups:/backups - restart: unless-stopped +version: '3.8' +services: + db: + container_name: qgis-plugins-db + image: kartoza/postgis:15-3.3 + environment: + - ALLOW_IP_RANGE=0.0.0.0/0 + - POSTGRES_USER=${POSTGRES_USER:-docker} + - POSTGRES_PASS=${POSTGRES_PASS:-docker} + - POSTGRES_DBNAME=${DATABASE_NAME:-gis},${METABASE_DATABASE_NAME:-metabase} + volumes: + - ./backups:/backups + restart: unless-stopped -web: - # Note you cannot scale if you use container_name - container_name: qgis-plugins-web - build: docker - hostname: uwsgi - environment: - - DATABASE_NAME=gis - - DATABASE_USERNAME=docker - - DATABASE_PASSWORD=docker - - DATABASE_HOST=db - - DJANGO_SETTINGS_MODULE=settings_docker - - VIRTUAL_HOST=plugins.kartoza.com - - VIRTUAL_PORT=8080 - - DEBUG=False - - RABBITMQ_HOST=rabbitmq - volumes: - - ../qgis-app:/home/web/django_project - - ./static:/home/web/static:rw - - ./static:/home/web/media:rw - links: - - db:db - - rabbitmq:rabbitmq - - worker:worker - restart: unless-stopped - user: root - command: uwsgi --ini /uwsgi.conf + web: + # Note you cannot scale if you use container_name + container_name: qgis-plugins-web + build: docker + hostname: uwsgi + environment: + - DATABASE_NAME=${DATABASE_NAME:-gis} + - DATABASE_USERNAME=${DATABASE_USERNAME:-docker} + - DATABASE_PASSWORD=${DATABASE_USERNAME:-docker} + - DATABASE_HOST=db + - DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-settings_docker} + - VIRTUAL_HOST=plugins.kartoza.com + - VIRTUAL_PORT=8080 + - RABBITMQ_HOST=${RABBITMQ_HOST:-rabbitmq} + - DEBUG=False + volumes: + - ../qgis-app:/home/web/django_project + - ./static:/home/web/static:rw + - ./static:/home/web/media:rw + depends_on: + - worker + - metabase + restart: unless-stopped + user: root + command: uwsgi --ini /uwsgi.conf -devweb: - # Note you cannot scale if you use container_name - container_name: qgis-plugins-devweb - build: docker - hostname: uwsgi - environment: - - DATABASE_NAME=gis - - DATABASE_USERNAME=docker - - DATABASE_PASSWORD=docker - - DATABASE_HOST=db - - DJANGO_SETTINGS_MODULE=settings_docker - - VIRTUAL_HOST=plugins.kartoza.com - - VIRTUAL_PORT=8080 - - RABBITMQ_HOST=rabbitmq - volumes: - - ../qgis-app:/home/web/django_project - - ./static:/home/web/static:rw - - ./static:/home/web/media:rw - links: - - db:db - - rabbitmq:rabbitmq - - worker:worker - restart: unless-stopped - user: root - ports: - # for django test server - - "62202:8080" - # for ssh - - "62203:22" + devweb: + # Note you cannot scale if you use container_name + container_name: qgis-plugins-devweb + build: docker + hostname: uwsgi + environment: + - DATABASE_NAME=${DATABASE_NAME:-gis} + - DATABASE_USERNAME=${DATABASE_USERNAME:-docker} + - DATABASE_PASSWORD=${DATABASE_USERNAME:-docker} + - DATABASE_HOST=db + - DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-settings_docker} + - VIRTUAL_HOST=plugins.kartoza.com + - VIRTUAL_PORT=8080 + - RABBITMQ_HOST=${RABBITMQ_HOST:-rabbitmq} + volumes: + - ../qgis-app:/home/web/django_project + - ./static:/home/web/static:rw + - ./static:/home/web/media:rw + depends_on: + - worker + restart: unless-stopped + user: root + ports: + # for django test server + - "62202:8080" + # for ssh + - "62203:22" -rabbitmq: - image: library/rabbitmq:3.6 - hostname: rabbitmq - environment: - - RABBIT_PASSWORD=rabbit_test_password - - USER=rabbit_user - - RABBITMQ_NODENAME=rabbit - restart: unless-stopped + rabbitmq: + image: library/rabbitmq:3.6 + hostname: rabbitmq + environment: + - RABBIT_PASSWORD=rabbit_test_password + - USER=rabbit_user + - RABBITMQ_NODENAME=rabbit + restart: unless-stopped -worker: - # Note you cannot scale if you use container_name - container_name: qgis-plugins-worker - build: docker - hostname: uwsgi - working_dir: /home/web/django_project - command: celery -A plugins worker -l info - environment: - - DATABASE_NAME=gis - - DATABASE_USERNAME=docker - - DATABASE_PASSWORD=docker - - DATABASE_HOST=db - - DJANGO_SETTINGS_MODULE=settings_docker - - VIRTUAL_HOST=plugins.kartoza.com - - VIRTUAL_PORT=8080 - - RABBITMQ_HOST=rabbitmq - volumes: - - ../qgis-app:/home/web/django_project - - ./static:/home/web/static:rw - - ./static:/home/web/media:rw - links: - - db:db - - rabbitmq:rabbitmq + worker: + # Note you cannot scale if you use container_name + container_name: qgis-plugins-worker + build: docker + hostname: uwsgi + working_dir: /home/web/django_project + command: celery -A plugins worker -l info + environment: + - DATABASE_NAME=${DATABASE_NAME:-gis} + - DATABASE_USERNAME=${DATABASE_USERNAME:-docker} + - DATABASE_PASSWORD=${DATABASE_USERNAME:-docker} + - DATABASE_HOST=db + - DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-settings_docker} + - VIRTUAL_HOST=plugins.kartoza.com + - VIRTUAL_PORT=8080 + - RABBITMQ_HOST=${RABBITMQ_HOST:-rabbitmq} + volumes: + - ../qgis-app:/home/web/django_project + - ./static:/home/web/static:rw + - ./static:/home/web/media:rw + depends_on: + - db + - rabbitmq -nginx: - # Note you cannot scale if you use container_name - container_name: qgis-plugins-nginx - image: nginx - hostname: nginx - volumes: - - ./sites-enabled:/etc/nginx/conf.d:ro - # I dont use volumes_from as I want to use the ro modifier - - ./static:/home/web/static:ro - - ./static:/home/web/media:ro - - ./logs:/var/log/nginx - links: - - web:uwsgi - ports: - - "62201:8080" - restart: unless-stopped + nginx: + # Note you cannot scale if you use container_name + container_name: qgis-plugins-nginx + image: nginx + hostname: nginx + volumes: + - ./sites-enabled:/etc/nginx/conf.d:ro + # I dont use volumes_from as I want to use the ro modifier + - ./static:/home/web/static:ro + - ./static:/home/web/media:ro + - ./logs:/var/log/nginx + links: + - web:uwsgi + ports: + - "62201:8080" + restart: unless-stopped + + metabase: + container_name: metabase + image: metabase/metabase:${METABASE_TAG:-latest} + environment: + - MB_DB_TYPE=postgres + - MB_DB_DBNAME=${METABASE_DATABASE_NAME:-metabase} + - MB_DB_PORT=5432 + - MB_DB_USER=${DATABASE_USERNAME:-docker} + - MB_DB_PASS=${DATABASE_PASSWORD:-docker} + - MB_DB_HOST=db + ports: + - "3000:3000" + depends_on: + - db + restart: unless-stopped