From ae08547fa6f21f8c63269313ac681b1ea42e8315 Mon Sep 17 00:00:00 2001
From: mjanez <96422458+mjanez@users.noreply.github.com>
Date: Thu, 20 Apr 2023 10:17:21 +0000
Subject: [PATCH] Create a quick deploy docker compose file
- Remove ckan-spatial from default docker compose file
- Create a docker-compose.ghcr.yml to use the ckan-spatial image from container registry
- Update the README to include this information
- Update .env.example to info about CKAN_VERSION ennvar
---
.env.example | 1 +
README.md | 29 +++++----
docker-compose.ghcr.yml | 129 +++++++++++++++++++++++++++++++++++++++
docker-compose.nginx.yml | 1 -
docker-compose.yml | 1 -
5 files changed, 146 insertions(+), 15 deletions(-)
create mode 100644 docker-compose.ghcr.yml
diff --git a/.env.example b/.env.example
index c203aff..79052f5 100644
--- a/.env.example
+++ b/.env.example
@@ -66,6 +66,7 @@ TEST_CKAN_DATASTORE_WRITE_URL=postgresql://ckan:ckan@db/datastore_test
TEST_CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore_test
# CKAN core
+## If use docker-compose.ghcr.yml only "*.*.*" versions available in: https://github.com/mjanez/ckan-docker/pkgs/container/ckan-spatial
CKAN_VERSION=2.9.8
CKAN_SITE_ID=default
# CKAN_SITE_URL = http:/ or https:/ + APACHE_SERVER_NAME. Optionally the APACHE_HOST_PORT if different from 80
diff --git a/README.md b/README.md
index 643de9f..94884d3 100644
--- a/README.md
+++ b/README.md
@@ -198,30 +198,22 @@ Use this if you are a maintainer and will not be making code changes to CKAN or
```bash
docker compose build
```
+
>**Note**
- > NGINX CKAN without ckan-pycsw and Apache:
- >```bash
- >docker compose -f docker-compose.nginx.yml build
- >```
-
+ > You can use a [deploy in 5 minutes](#quick-mode) if you just want to test the package.
4. Start the containers:
```bash
docker compose up
```
- >**Note**
- > NGINX CKAN without ckan-pycsw and Apache:
- >```bash
- >docker compose -f docker-compose.nginx.yml up
- >```
-
This will start up the containers in the current window. By default the containers will log direct to this window with each container
using a different colour. You could also use the -d "detach mode" option ie: `docker compose up -d` if you wished to use the current
window for something else.
>**Note**
-> Or `docker compose up --build` to build & up the containers.
+> * Or `docker compose up --build` to build & up the containers.
+> * Or `docker compose -f docker-compose.nginx.yml up -d --build` to use the NGINX version.
At the end of the container start sequence there should be 6 containers running (or 5 if use NGINX Docker Compose file)
@@ -234,7 +226,7 @@ After this step, CKAN should be running at {`APACHE_SERVER_NAME`}{`APACHE_CKAN_L
|1b8d9789c29a|redis:7-alpine |docker-entrypoint.s…|6 minutes ago |Up 4 minutes (healthy)|6379/tcp |redis | |
|7f162741254d|ckan/ckan-solr:2.9-solr8-spatial |docker-entrypoint.s…|6 minutes ago |Up 4 minutes (healthy)|8983/tcp |solr | |
|2cdd25cea0de|ckan-docker-db |docker-entrypoint.s…|6 minutes ago |Up 4 minutes (healthy)|5432/tcp |db | |
-|9cdj25dae6gr|ckan-docker-pycsw |docker-entrypoint.s…|6 minutes ago |Up 4 minutes (healthy)|8000/tcp |db | |
+|9cdj25dae6gr|ckan-docker-pycsw |docker-entrypoint.s…|6 minutes ago |Up 4 minutes (healthy)|8000/tcp |pycsw | |
#### Configure a docker compose service to start on boot
@@ -293,6 +285,17 @@ To have Docker Compose run automatically when you reboot a machine, you can foll
sudo systemctl status ckan-docker-compose
```
+### Quick mode
+If you just want to test the package and see the general functionality of the platform, you can use the `ckan-spatial` image from the [Github container registry](https://github.com/mjanez/ckan-docker/pkgs/container/ckan-spatial):
+
+ ```bash
+ cp .env.example .env
+ # Edit the envvars in the .env as you like and start the containers.
+ docker compose -f docker-compose.ghcr.yml up -d --build
+ ```
+
+It will download the pre-built image and deploy all the containers. Remember to use your own domain by changing `localhost` in the `.env` file.
+
### Development mode
Use this mode if you are making code changes to CKAN and either creating new extensions or making code changes to existing extensions. This mode also uses the `.env` file for config options.
diff --git a/docker-compose.ghcr.yml b/docker-compose.ghcr.yml
new file mode 100644
index 0000000..637fab3
--- /dev/null
+++ b/docker-compose.ghcr.yml
@@ -0,0 +1,129 @@
+version: "3"
+
+volumes:
+ ckan_storage:
+ pg_data:
+ solr_data:
+
+services:
+
+ apache:
+ container_name: ${APACHE_CONTAINER_NAME}
+ build:
+ context: apache/
+ dockerfile: Dockerfile
+ env_file:
+ - .env
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ depends_on:
+ ckan:
+ condition: service_healthy
+ ports:
+ - "0.0.0.0:${APACHE_PORT_HOST}:${APACHE_PORT}"
+ restart: on-failure:3
+
+ ckan:
+ container_name: ${CKAN_CONTAINER_NAME}
+ image: ghcr.io/mjanez/ckan-spatial:ckan-${CKAN_VERSION}
+ env_file:
+ - .env
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ depends_on:
+ db:
+ condition: service_healthy
+ solr:
+ condition: service_healthy
+ redis:
+ condition: service_healthy
+ ports:
+ - "0.0.0.0:${CKAN_PORT_HOST}:${CKAN_PORT}"
+ volumes:
+ - ckan_storage:/var/lib/ckan
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:${CKAN_PORT}"]
+
+ pycsw:
+ container_name: ${PYCSW_CONTAINER_NAME}
+ build:
+ context: ckan-pycsw/
+ dockerfile: Dockerfile
+ env_file:
+ - .env
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ depends_on:
+ ckan:
+ condition: service_healthy
+ ports:
+ - "0.0.0.0:${PYCSW_PORT_HOST}:${PYCSW_PORT}"
+ volumes:
+ - ./log:${APP_DIR}/log
+ - ./metadata:${APP_DIR}/metadata
+ restart: on-failure:3
+ healthcheck:
+ test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:${PYCSW_PORT}"]
+
+ db:
+ container_name: ${POSTGRESQL_CONTAINER_NAME}
+ build:
+ context: postgresql/
+ args:
+ - DATASTORE_READONLY_PASSWORD=${DATASTORE_READONLY_PASSWORD}
+ - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
+ environment:
+ - DATASTORE_READONLY_PASSWORD=${DATASTORE_READONLY_PASSWORD}
+ - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
+ - PGDATA=/var/lib/postgresql/data/db
+ volumes:
+ - pg_data:/var/lib/postgresql/data
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "pg_isready", "-U", "ckan"]
+
+ solr:
+ container_name: ${SOLR_CONTAINER_NAME}
+ build:
+ context: solr/
+ dockerfile: Dockerfile.spatial
+ image: ckan/ckan-solr:${SOLR_IMAGE_VERSION}
+ env_file:
+ - .env
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ volumes:
+ - solr_data:/var/solr
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:${SOLR_PORT}/solr/"]
+
+ redis:
+ container_name: ${REDIS_CONTAINER_NAME}
+ image: redis:${REDIS_VERSION}
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "100m"
+ max-file: "10"
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "redis-cli", "-e", "QUIT"]
diff --git a/docker-compose.nginx.yml b/docker-compose.nginx.yml
index 8ffbd32..68ccd01 100644
--- a/docker-compose.nginx.yml
+++ b/docker-compose.nginx.yml
@@ -32,7 +32,6 @@ services:
build:
context: ckan/
dockerfile: Dockerfile
- image: ghcr.io/mjanez/ckan-spatial:ckan-2.9.8
env_file:
- .env
logging:
diff --git a/docker-compose.yml b/docker-compose.yml
index 739b9c8..f99afdd 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -31,7 +31,6 @@ services:
build:
context: ckan/
dockerfile: Dockerfile
- image: ghcr.io/mjanez/ckan-spatial:ckan-2.9.8
env_file:
- .env
logging: