Skip to content

Instantly share code, notes, and snippets.

@gannebamm
Created January 14, 2021 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gannebamm/98e25a218113c56142dda2ad71f72637 to your computer and use it in GitHub Desktop.
Save gannebamm/98e25a218113c56142dda2ad71f72637 to your computer and use it in GitHub Desktop.
Setup GeoNode with docker-compose on a Ubuntu 20.04

install tisdar based GeoNode as docker composition on Ubuntu 20.04 LTS

User

sudo adduser geonode
sudo usermod -aG sudo geonode

Docker Setup

Install the Docker and docker-compose packages

sudo add-apt-repository universe
sudo apt-get update -y
sudo apt-get install -y git-core git-buildpackage debhelper devscripts
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
sudo apt autoremove --purge

sudo usermod -aG docker geonode
su geonode

Create folder structure and clone repo

sudo mkdir -p /opt/geonode/
sudo usermod -a -G www-data geonode
sudo chown -Rf geonode:www-data /opt/geonode/
sudo chmod -Rf 775 /opt/geonode/
cd /opt
git clone https://github.com/gannebamm/geonode.git -b tisdar@master geonode

Get latest postgis docker image

We have a PullRequest ongoing for a new PostGIS container. Therefore we should use the PRs Dockerfile:

sudo mkdir -p /opt/postgis-docker/
sudo chown -Rf tisdex:www-data /opt/postgis-docker/
sudo chmod -Rf 775 /opt/postgis-docker/

git clone https://github.com/csgis/postgis-docker -b master postgis-docker

To use this updated PostGIS image we have to built it. To get recognized by our GeoNode composition we also have to label it accordingly

cd /opt/postgis-docker
docker build -t geonode/postgis:latest .

Configure GeoNode instance

There is only one .env file to configure:

cd /opt/geonode
nano .env

And if you want to use your own SSL certificates you will have to bind your certificates folder inside the nginx container. You should do this by changing the docker-compose.yml like this:

nano docker-compose.yml

  # Nginx is serving django static and media files and proxies to django and geonode
  geonode:
    image: geonode/nginx:3.x
    build: ./scripts/docker/nginx/
    container_name: nginx4${COMPOSE_PROJECT_NAME}
    env_file:
      - .env
    environment:
      - HTTPS_HOST=${HTTPS_HOST}
      - HTTP_HOST=${HTTP_HOST}
      - HTTPS_PORT=${HTTPS_PORT}
      - HTTP_PORT=${HTTP_PORT}
      - LETSENCRYPT_MODE=${LETSENCRYPT_MODE}
      - RESOLVER=127.0.0.11
    ports:
      - "${HTTP_PORT}:80"
      - "${HTTPS_PORT}:443"
    volumes:
      - nginx-confd:/etc/nginx
      ### comment the below out
      # - nginx-certificates:/geonode-certificates
      - /your/secure/path/on/host:/geonode-certificates
      - statics:/mnt/volumes/statics
    restart: on-failure

With the example above your SSL certificate and private key should look like:

/your/secure/path/on/host/fullchain.pem
/your/secure/path/on/host/privkey.pem

You also should change the .env http paths to use https, if they do not point to local containers (like geoserver internal calls)

examples env variables for a SSL certificate for tisdar.dev.thuenen.de in .env:

SITEURL=https://tisdar.dev.thuenen.de/
HTTP_HOST=   # << empty
HTTPS_HOST=tisdar.dev.thuenen.de
HTTP_PORT=80
HTTPS_PORT=443

GEOSERVER_WEB_UI_LOCATION=https://tisdar.dev.thuenen.de/geoserver/
GEOSERVER_PUBLIC_LOCATION=https://tisdar.dev.thuenen.de/geoserver/
GEOSERVER_LOCATION=http://geoserver:8080/geoserver/ # << http!

GEOSERVER_LOCATION is a local container inside the docker network. You do not use https for those calls.

Build and run instance

cd /opt/geonode
docker-compose build

This will take a while and should work without errors. After the built was successful you can start the composition.

docker-compose up

Take a look at the logs. There will be errors due to containers which need other containers, which are not yet ready. They will restart and should finish with lines looking like this:

django4geonode    | monitoringfixture task done
django4geonode    | initialized
django4geonode    | refresh static data
django4geonode    | static data refreshed
django4geonode    | waitforgeoserver task done
django4geonode    | geoserverfixture task done
django4geonode    | updateadmin task done
django4geonode    | Executing UWSGI server uwsgi --ini /usr/src/geonode/uwsgi.ini for Production
django4geonode    | -----------------------------------------------------
django4geonode    | FINISHED DJANGO ENTRYPOINT --------------------------
django4geonode    | -----------------------------------------------------
django4geonode    | got command uwsgi --ini /usr/src/geonode/uwsgi.ini
django4geonode    | [uWSGI] getting INI configuration from /usr/src/geonode/uwsgi.ini
rabbitmq4geonode  | 2021-01-14 13:30:08.758 [info] <0.673.0> accepting AMQP connection <0.673.0> (172.18.0.4:48624 -> 172.18.0.2:5672)
rabbitmq4geonode  | 2021-01-14 13:30:08.761 [info] <0.673.0> connection <0.673.0> (172.18.0.4:48624 -> 172.18.0.2:5672): user 'guest' authenticated and granted access to vhost '/'
nginx4geonode     | 172.18.0.1 - - [14/Jan/2021:13:30:08 +0000] "GET /monitoring/api/beacon/hostgeonode/ HTTP/1.1" 200 571 "-" "python-requests/2.25.1"

And it´s done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment