Skip to content

Commit

Permalink
Version 1
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Feb 10, 2021
0 parents commit 44c46a5
Show file tree
Hide file tree
Showing 1,018 changed files with 169,541 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MERGIN_USER=foo
MERGIN_PASSWORD=bar

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
certbot/certbot
postgis_data/
mergin_sync_data/
1 change: 1 addition & 0 deletions QGIS-Server-PG-Project-Design.drawio

Large diffs are not rendered by default.

Binary file added QGIS-Server-PG-Project-Design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QGISWMSClientConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 168 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# oq-qgis-server
# Copyright (C) 2018-2019 GEM Foundation
#
# oq-qgis-server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# oq-qgis-server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

version: '2'
services:
db:
image: kartoza/postgis:13.0
volumes:
- ./postgis_data:/var/lib/postgresql
environment:
- POSTGRES_DB=gis
- POSTGRES_USER=docker
- POSTGRES_PASS=docker
- ALLOW_IP_RANGE=0.0.0.0/0
networks:
- qgis-server-net
ports:
- 5432:5432
restart: unless-stopped

mergin-sync:
image: "mergin_db_sync"
volumes:
# We do this so we can easily inspect what is being pulled down
# from merging, flush the working dir when needed etc
- ./mergin_sync_data:/tmp
environment:
- DB_CONN_INFO=host=db dbname=gis user=docker password=docker
- DB_SCHEMA_MODIFIED=sync_main
- DB_SCHEMA_BASE=sync_base
- MERGIN_USERNAME=${MERGIN_USER}
- MERGIN_PASSWORD=${MERGIN_PASSWORD}
- MERGIN_PROJECT_NAME=tim1/Maceira
- MERGIN_SYNC_FILE=smallholding.gpkg
entrypoint: "python3 dbsync_daemon.py --init-from-gpkg"
#entrypoint: "python3 dbsync_daemon.py"
networks:
- qgis-server-net
restart: unless-stopped
depends_on:
- db

nginx:
image: "nginx"
volumes:
- ./html:/var/www/html
- ./nginx_conf/nginx.conf:/etc/nginx/nginx.conf
- ./certbot/certbot/conf:/etc/letsencrypt
- ./certbot/certbot/www:/var/www/certbot
# This makes nginx reload its configuration (and certificates) every six hours in the background and launches nginx in the foreground.
# See https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
ports:
- "80:80"
- "443:443"
networks:
- qgis-server-net
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 200m
max-file: '10'
depends_on:
- qgis-server
- mapproxy

certbot:
image: certbot/certbot
# This checks every 12 hours if our cert is up for renewal and refreshes it if needed
# See https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
- ./certbot/certbot/conf:/etc/letsencrypt
- ./certbot/certbot/www:/var/www/certbot

qgis-server:
image: "openquake/qgis-server:stable"
#image: "openquake/qgis-server:3"
environment:
# Do not run the embedded copy of nginx
SKIP_NGINX: "true"
# Improve rendering performance
QGIS_SERVER_PARALLEL_RENDERING: "true"
QGIS_SERVER_MAX_THREADS: 4
# Limit the maximum size returned by a GetMap
QGIS_SERVER_WMS_MAX_HEIGHT: 5000
QGIS_SERVER_WMS_MAX_WIDTH: 5000
# Verbose logging
QGIS_SERVER_LOG_LEVEL: 0
ports:
- "9993:9993"
networks:
- qgis-server-net
volumes:
# Data should be mount RO when working
# with GeoPackages and more than one QGIS container
# Data dir structure
# $(pwd)/qgis_projects must have the following structure:
# data
# |
# |-- <project_name>
# |-- <project_name>.qgs
- ./qgis_projects:/io/data:ro
#
# qgis_plugins
# |
# |-- <plugin_name>
# |-- <plugin_code>.py
# |-- metadata.txt
# |-- __init__.py
- ./qgis_plugins:/io/plugins
# Custom fonts are loaded into /usr/share/fonts. fc-cache is run when container is started.
- ./fonts:/usr/share/fonts
- ./svg:/var/lib/qgis/.local/share/QGIS/QGIS3/profiles/default/svg
# I wanted to share the qgis auth db like this and set
# QGIS_AUTH_PASSWORD_FILE in nginx
# but it is not working so I am trying the explicit mounts below instead
#- ./qgis_conf:/qgis_config
- ./qgis_conf/qgis-auth.db:/tmp/qgis-auth.db
- ./qgis_conf/qgis-auth-pwd.txt:/tmp/qgis-auth-pwd.txt
# Working path for the pg_service file if using openquake/qgis-server:stable
# See https://github.com/gem/oq-qgis-server/issues/54
# The service file contains two service definitions
# nginx - used for connecting to the database to load a QGIS project stored in the database
# In that case you cannot yet use qgis-auth.db database for user/pass credentials
# smallholding - used for layer definitions. This service has no user/pass data and
# instead we fetch those credentials from the qgis authdb
- ./pg_conf/pg_service.conf:/etc/postgresql-common/pg_service.conf:ro
# As per the oq QGIS Server docs at https://github.com/gem/oq-qgis-server/blob/master/README.md#postgresql-connection-service-file-optional but wrong!
#This works instead for the openquake/qgis-server:3 image
#- ./pg_conf/pg_service.conf:/etc/pg_service.conf:ro
depends_on:
- db
restart: unless-stopped

mapproxy:
image: kartoza/mapproxy
environment:
- PRODUCTION=false
- PROCESSES=4
- THREADS=10
user: "1000:10001"
volumes:
- ./mapproxy_conf:/mapproxy
depends_on:
- qgis-server
networks:
- qgis-server-net

networks:
qgis-server-net:
61 changes: 61 additions & 0 deletions html/file-based-map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>

<title>WMS example - Leaflet</title>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>


<style>
html, body {
height: 100%;
margin: 0;
}
#map {
width: 100%;
height: 100%;
}
</style>


</head>
<body>

<div id='map'></div>

<script type="text/javascript">

var map = L.map('map', {
center: [-7.38531083,39.41239033],
zoom: 3
});

// get the layer via mapproxy in front of QGIS Server
var portugal_mapproxy = L.tileLayer.wms('https://castelo.kartoza.com/mapproxy/service?', {
layers: 'portugal',
format: 'image/png',
uppercase: true,
transparent: true,
continuousWorld: true,
opacity: 1.0
}).addTo(map);

// get the layer straight from QGIS Server
var wmsLayer = L.tileLayer.wms('https://castelo.kartoza.com/ogc/demo?', {
layers: 'portugal'
}).addTo(map);

</script>



</body>
</html>

3 changes: 3 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Maps here</h1>
<p>QGIS Project Stored in PostGIS: <a href="pg-map.html">PG Map</a></p>
<p>QGIS Project Store in File System: <a href="file-based-map.html">File Based Map</a></p>
29 changes: 29 additions & 0 deletions html/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'ol/ol.css';
import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import TileLayer from 'ol/layer/Tile';
import TileWMS from 'ol/source/TileWMS';
import View from 'ol/View';

var layers = [
new TileLayer({
source: new OSM(),
}),
new TileLayer({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {'LAYERS': 'topp:states', 'TILED': true},
serverType: 'geoserver',
// Countries have transparency, so do not fade tiles:
transition: 0,
}),
}) ];
var map = new Map({
layers: layers,
target: 'map',
view: new View({
center: [-10997148, 4569099],
zoom: 4,
}),
});
57 changes: 57 additions & 0 deletions html/ol/AssertionError.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions html/ol/AssertionError.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 44c46a5

Please sign in to comment.