Closed d3netxer closed 2 years ago
You can use one of the files for version 4 and customise it.
Basically you will need to use the geonetwork:3-postgres
image and define the POSTGRES_DB_USERNAME
, POSTGRES_DB_PASSWORD
, POSTGRES_DB_PORT
, POSTGRES_DB_NAME
and POSTGRES_DB_HOST
environment variables in the GeoNetwork container to connect to the postgres database.
Thank you, this is the route I was thinking, and your comment is making me more confident. I will proceed.
I'm not really sure why I'm having problems, but it wasn't working for me today. I think the piece that wasn't working is routing to the public IP address...
However, I was able to successfully deploy using the H2 database. Here is my docker-compose.yml:
version: '3.1'
services:
www:
image: nginx
ports:
- 80:80
volumes:
- ./dev-env/nginx/nginx.conf:/etc/nginx/nginx.conf
geonetwork:
image: 'geonetwork:3.12.6'
restart: always
ports:
- 8080:8080
environment:
DATA_DIR: /var/lib/geonetwork_data
volumes:
- geonetwork:/var/lib/geonetwork_data
volumes:
geonetwork:
and here is my nginx.conf:
events {}
http {
server {
listen 80;
location / {
proxy_pass http://172.17.0.1:8080;
}
}
}
I'm not really sure how in the 4x example GeoNetwork is able to host the application without doing the reverse-proxy I did, but I suspect it has something to do with the different services all being on the same network on the docker-compose file.
This works for me:
docker-compose.yml
version: '3.1'
services:
www:
image: nginx
ports:
- 80:80
volumes:
- ./dev-env/nginx/nginx.conf:/etc/nginx/nginx.conf
geonetwork:
image: 'geonetwork:3.12.6'
restart: always
environment:
DATA_DIR: /var/lib/geonetwork_data
volumes:
- geonetwork:/var/lib/geonetwork_data
volumes:
geonetwork:
With this nginx.conf
file:
events {
worker_connections 4096; ## Default: 1024
}
http {
server {
listen 80;
access_log /var/log/nginx/gn-access.log;
error_log /var/log/nginx/gn-error.log;
location / {
server_name_in_redirect off;
return 301 /geonetwork;
}
location /geonetwork {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_pass http://geonetwork:8080/geonetwork;
}
}
}
Thanks for sharing @juanluisrp.
I was working on docker compose the past few days, and I was able to come up with a configuration that let's me install GeoNetwork, GeoServer, along with them using PostGIS as a backend, and let me proxy them all using NGINX. Note that I am also using certbot to get a certificate and I am using SSH.
I will share below:
version: '3.9'
services:
# read this article to guide implementing SSH (https://mindsers.blog/post/https-using-nginx-certbot-docker/) but changed paths on host machine
# for example /var/www/certbot, /etc/letsencrypt
nginx:
image: nginx:1.15-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf/:/etc/nginx/conf.d/
- /var/www/test:/var/www/test
- /var/www/certbot:/var/www/certbot
- /etc/letsencrypt:/etc/letsencrypt
- ./nginx/logs:/var/log/nginx
#- /etc/letsencrypt/:/etc/nginx/ssl/
#- ./data/certbot/conf:/etc/letsencrypt
#- ./certbot/www:/var/www/certbot
certbot:
image: certbot/certbot
volumes:
#- ./data/certbot/conf:/etc/letsencrypt
#- .certbot/www:/var/www/certbot
- /var/www/certbot:/var/www/certbot
- /etc/letsencrypt/:/etc/letsencrypt/
# the postgres db container
# for some reason the POSTGRES_DB_HOST environment variable doesn't work on the geonetwork service, so this service has to be named 'postgres' for geonetwork to be able to network
postgres:
image: kartoza/postgis:14-3.2
volumes:
- postgis-data:/var/lib/postgresql
ports:
- 5432:5432
environment:
# If you need to create multiple database you can add coma separated databases eg gis,data
- POSTGRES_DB=gis,hiu
- POSTGRES_USER=docker
- POSTGRES_PASS=docker
- ALLOW_IP_RANGE=0.0.0.0/0
# Add extensions you need to be enabled by default in the DB. Default are the five specified below
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
restart: on-failure
healthcheck:
test: "exit 0"
# as of right now (9/27/2022) GeoServer versions 2.19 and 2.20 do not allow proxied log-ins: https://osgeo-org.atlassian.net/browse/GEOS-10158
# added environment variables to connect to postgres: https://github.com/kartoza/docker-geoserver#enable-disk-quota-storage-in-postgresql-backend
geoserver:
image: kartoza/geoserver:2.18.2
volumes:
- geoserver-data:/opt/geoserver/data_dir
ports:
- 8081:8080
restart: on-failure
environment:
- GEOSERVER_DATA_DIR=geonetwork
- GEOWEBCACHE_CACHE_DIR=/opt/geoserver/data_dir/gwc
- GEOSERVER_ADMIN_PASSWORD=geonetwork
- GEOSERVER_ADMIN_USER=geonetwork
- INITIAL_MEMORY=2G
- MAXIMUM_MEMORY=4G
- DB_BACKEND=POSTGRES
- HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=gis
- POSTGRES_USER=docker
- POSTGRES_PASS=docker
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: curl --fail -s http://localhost:8080/ || exit 1
interval: 1m30s
timeout: 10s
retries: 3
geonetwork:
image: 'geonetwork:3.12.7-postgres'
restart: always
ports:
- 8080:8080
environment:
- DATA_DIR=/var/lib/geonetwork_data
- POSTGRES_DB_USERNAME=docker
- POSTGRES_DB_PASSWORD=docker
volumes:
- geonetwork:/var/lib/geonetwork_data
volumes:
geonetwork:
geoserver-data:
postgis-data:
# located at nginx/nginx.conf
# This is the main nginx configuration file
events {}
http {
include /etc/nginx/conf.d/*.conf;
}
stream {
server {
listen 5431 so_keepalive=on;
proxy_connect_timeout 60s;
proxy_socket_keepalive on;
proxy_pass localhost:5432;
}
}
# file located at nginx/conf/app.conf
server {
listen 80;
server_name example.com;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location /test {
default_type text/html;
return 200 "<!DOCTYPE html><h2>test connection!</h2>\n";
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location /geonetwork {
proxy_pass http://172.17.0.1:8080/geonetwork;
}
location /geoserver {
proxy_pass http://172.17.0.1:8081/geoserver;
}
location / {
default_type text/html;
return 200 "<!DOCTYPE html><h2>test SSH connection!</h2>\n";
}
}
Does somebody have a docker-compose file to share for geonetwork version 3?
I would like to have it running along with NGINX and POSTGRES. I am only seeing docker files in the repo for geonetwork version 3.