Skip to content

Commit

Permalink
Merge pull request ckan#6244 from Gauravp-NEC/Fix-for-issue-4845
Browse files Browse the repository at this point in the history
 Hardcoded references to db host and users removed
  • Loading branch information
kowh-ai authored Mar 15, 2022
2 parents 0e6c254 + 35fbb19 commit 53372d3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
12 changes: 9 additions & 3 deletions contrib/docker/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ CKAN_SMTP_MAIL_FROM=ckan@localhost
# Image: db
POSTGRES_PASSWORD=ckan
#
# POSTGRES_USER must be set to the database user used by CKAN, typically named ckan
POSTGRES_USER=ckan
#
# POSTGRES_PORT must be available on the host: sudo netstat -na | grep 5432
# To apply change: docker-compose down && docker rmi docker_db docker_ckan && docker-compose build
POSTGRES_PORT=5432
#
# The datastore database will be created in the db container as docs
# Readwrite user/pass will be ckan:POSTGRES_PASSWORD
# Readonly user/pass will be datastore_ro:DATASTORE_READONLY_PASSWORD
# Readwrite user/pass will be POSTGRES_USER:POSTGRES_PASSWORD
# Readonly user/pass will be DATASTORE_READONLY_USER:DATASTORE_READONLY_PASSWORD
DATASTORE_READONLY_PASSWORD=datastore

DATASTORE_READONLY_USER=datastore_ro
# POSTGRES_HOST must be set to the host for the postgres server.
# As a default 'db' will point to the postgres running in the docker container specified by the docker-compose.yml file.
POSTGRES_HOST=db
2 changes: 1 addition & 1 deletion contrib/docker/ckan-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ write_config () {
}

# Wait for PostgreSQL
while ! pg_isready -h db -U ckan; do
while ! pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}"; do
sleep 1;
done

Expand Down
9 changes: 5 additions & 4 deletions contrib/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ services:
- "0.0.0.0:${CKAN_PORT}:5000"
environment:
# Defaults work with linked containers, change to use own Postgres, SolR, Redis or Datapusher
- CKAN_SQLALCHEMY_URL=postgresql://ckan:${POSTGRES_PASSWORD}@db/ckan
- CKAN_DATASTORE_WRITE_URL=postgresql://ckan:${POSTGRES_PASSWORD}@db/datastore
- CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:${DATASTORE_READONLY_PASSWORD}@db/datastore
- CKAN_SQLALCHEMY_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/ckan
- CKAN_DATASTORE_WRITE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/datastore
- CKAN_DATASTORE_READ_URL=postgresql://${DATASTORE_READONLY_USER}:${DATASTORE_READONLY_PASSWORD}@${POSTGRES_HOST}/datastore
- CKAN_SOLR_URL=http://solr:8983/solr/ckan
- CKAN_REDIS_URL=redis://redis:6379/1
- CKAN_DATAPUSHER_URL=http://datapusher:8800
- CKAN_SITE_URL=${CKAN_SITE_URL}
- CKAN_MAX_UPLOAD_SIZE_MB=${CKAN_MAX_UPLOAD_SIZE_MB}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- DS_RO_PASS=${DATASTORE_READONLY_PASSWORD}
- POSTGRES_HOST=${POSTGRES_HOST}
restart: unless-stopped

volumes:
Expand All @@ -49,7 +50,7 @@ services:
restart: unless-stopped

db:
container_name: db
container_name: ${POSTGRES_HOST}
build:
context: ../../
dockerfile: contrib/docker/postgresql/Dockerfile
Expand Down
13 changes: 13 additions & 0 deletions doc/maintaining/installing/install-from-docker-compose.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ The location of these named volumes needs to be backed up in a production enviro
To migrate CKAN data between different hosts, simply transfer the content of the named volumes.
A detailed use case of data transfer will be discussed in step 5.

You have the option of using environment variables rather than hard coding the actual docker
container name. For example, if you want to remove the "db" container name replace "db" with
name of your environment variable in docker-compose.yml:

links:
- db

depends_on:
- db

db:
container_name: ${POSTGRES_HOST}

c. Convenience: paths to named volumes

The files inside named volumes reside on a long-ish path on the host.
Expand Down

0 comments on commit 53372d3

Please sign in to comment.