{"id":13557953,"url":"https://github.com/ckan/ckan-docker","last_synced_at":"2025-05-16T08:04:37.018Z","repository":{"id":22313794,"uuid":"25648986","full_name":"ckan/ckan-docker","owner":"ckan","description":"Scripts and images to run CKAN using Docker Compose","archived":false,"fork":false,"pushed_at":"2025-05-14T11:17:00.000Z","size":773,"stargazers_count":121,"open_issues_count":60,"forks_count":228,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-14T12:37:35.309Z","etag":null,"topics":["ckan","docker","docker-compose"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ckan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-10-23T17:22:48.000Z","updated_at":"2025-05-07T10:40:07.000Z","dependencies_parsed_at":"2023-01-11T21:34:17.167Z","dependency_job_id":"87559ddd-0d0f-4d3e-a414-7cd4eb00c677","html_url":"https://github.com/ckan/ckan-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckan%2Fckan-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckan%2Fckan-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckan%2Fckan-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckan%2Fckan-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckan","download_url":"https://codeload.github.com/ckan/ckan-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ckan","docker","docker-compose"],"created_at":"2024-08-01T12:04:38.686Z","updated_at":"2025-05-16T08:04:32.003Z","avatar_url":"https://github.com/ckan.png","language":"Shell","funding_links":[],"categories":["Python","docker"],"sub_categories":[],"readme":"# Docker Compose setup for CKAN\n\n\n* [1. Overview](#1-overview)\n* [2. Installing Docker](#2-installing-docker)\n* [3. docker compose vs docker-compose](#3-docker-compose-vs-docker-compose)\n* [4. Install (build and run) CKAN plus dependencies](#4-install-build-and-run-ckan-plus-dependencies)\n  * [Base mode](#base-mode)\n  * [Development mode](#development-mode)\n    * [Create an extension](#create-an-extension)\n    * [Running HTTPS on development mode](#running-https-on-development-mode)\n    * [Remote Debugging with VS Code](#remote-debugging-with-vs-code)\n    * [Updating the environment file for development mode](#updating-the-environment-file-for-development-mode)\n* [5. CKAN images](#5-ckan-images)\n  * [Extending the base images](#extending-the-base-images)\n  * [Applying patches](#applying-patches)\n* [6. Debugging with pdb](#6-debugging-with-pdb)\n* [7. Datastore and Datapusher](#7-datastore-and-datapusher)\n* [8. NGINX](#8-nginx)\n* [9. ckanext-envvars](#9-ckanext-envvars)\n* [10. CKAN_SITE_URL](#10-CKAN_SITE_URL)\n* [11. Manage new users](#11-manage-new-users)\n* [12. Changing the base image](#12-changing-the-base-image)\n* [13. Replacing DataPusher with XLoader](#13-replacing-datapusher-with-xLoader)\n\n\n## 1.  Overview\n\nThis is a set of configuration and setup files to run a CKAN site.\n\nThe CKAN images used are from the official CKAN [ckan-docker](https://github.com/ckan/ckan-docker-base) repo\n\nThe non-CKAN images are as follows:\n\n* DataPusher: CKAN's [pre-configured DataPusher image](https://github.com/ckan/ckan-docker-base/tree/main/datapusher).\n* PostgreSQL: Official PostgreSQL image. Database files are stored in a named volume.\n* Solr: CKAN's [pre-configured Solr image](https://github.com/ckan/ckan-solr). Index data is stored in a named volume.\n* Redis: standard Redis image\n* NGINX: latest stable nginx image that includes SSL and Non-SSL endpoints\n\nThe site is configured using environment variables that you can set in the `.env` file.\n\n## 2.  Installing Docker\n\nInstall Docker by following the following instructions: [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)\n\nTo verify a successful Docker installation, run `docker run hello-world` and `docker version`. These commands should output \nversions for client and server.\n\n## 3.  docker compose *vs* docker-compose\n\nAll Docker Compose commands in this README will use the V2 version of Compose ie: `docker compose`. The older version (V1) \nused the `docker-compose` command. Please see [Docker Compose](https://docs.docker.com/compose/compose-v2/) for\nmore information.\n\n## 4.  Install (build and run) CKAN plus dependencies\n\n### Base mode\n\nUse this if you are a maintainer and will not be making code changes to CKAN or to CKAN extensions\n\nCopy the included `.env.example` and rename it to `.env`. Modify it depending on your own needs.\n\n\u003e [!WARNING]\n\u003e There is a sysadmin user created by default with the values defined in `CKAN_SYSADMIN_NAME` and `CKAN_SYSADMIN_PASSWORD` (`ckan_admin` and `test1234` by default). These must be changed before running this setup as a public CKAN instance.\n\nTo build the images:\n\n\tdocker compose build\n\nTo start the containers:\n\n\tdocker compose up\n\nThis will start up the containers in the current window. By default the containers will log direct to this window with each container\nusing a different colour. You could also use the -d \"detach mode\" option ie: `docker compose up -d` if you wished to use the current \nwindow for something else.\n\nAt the end of the container start sequence there should be 6 containers running:\n\n```bash\n$ docker compose ps\nNAME                       IMAGE                              COMMAND                  SERVICE      CREATED         STATUS                   PORTS\nckan-docker-ckan-1         ckan-docker-ckan                   \"/srv/app/start_ckan…\"   ckan         4 minutes ago   Up 3 minutes (healthy)   5000/tcp\nckan-docker-datapusher-1   ckan/ckan-base-datapusher:0.0.20   \"sh -c 'uwsgi --plug…\"   datapusher   4 minutes ago   Up 4 minutes (healthy)   8800/tcp\nckan-docker-db-1           ckan-docker-db                     \"docker-entrypoint.s…\"   db           4 minutes ago   Up 4 minutes (healthy)\nckan-docker-nginx-1        ckan-docker-nginx                  \"/bin/sh -c 'openssl…\"   nginx        4 minutes ago   Up 2 minutes             80/tcp, 0.0.0.0:8443-\u003e443/tcp\nckan-docker-redis-1        redis:6                            \"docker-entrypoint.s…\"   redis        4 minutes ago   Up 4 minutes (healthy)\nckan-docker-solr-1         ckan/ckan-solr:2.10-solr9          \"docker-entrypoint.s…\"   solr         4 minutes ago   Up 4 minutes (healthy)\n```\n\nAfter this step, CKAN should be running at `CKAN_SITE_URL` (by default https://localhost:8443)\n\n\n### Development mode\n\nUse 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.\n\nTo develop local extensions use the `docker-compose.dev.yml` file with help from the scripts under `bin`:\n\ndev script | description\n--- | ---\n`bin/ckan …` | exec `ckan` cli within the ckan-dev container\n`bin/compose …` | dev docker compose commands\n`bin/generate_extension` | generate extension in `src` directory\n`bin/install_src` | install all extensions from `src` directory (ckan-dev does not need to be running)\n`bin/reload` | reload ckan within the ckan-dev container without restarting\n`bin/restart` | shut down and restart the whole ckan-dev container (use `bin/compose up -d` instead to reload new values from .env)\n`bin/shell` | exec bash prompt within the ckan-dev container\n\nTo build the images:\n\n\tbin/compose build\n\nTo install extensions from the `src` directory:\n\n\tbin/install_src\n\nTo start the containers:\n\n\tbin/compose up\n\nSee [CKAN images](#5-ckan-images) for more details of what happens when using development mode.\n\n\n#### Create an extension\n\nYou can use the ckan [extension](https://docs.ckan.org/en/latest/extensions/tutorial.html#creating-a-new-extension) instructions to create a CKAN extension, only executing the command inside the CKAN container and setting the mounted `src/` folder as output:\n\n        bin/generate_extension\n\n```\nExtension's name [must begin 'ckanext-']: ckanext-mytheme\nAuthor's name []: Joe Bloggs\nAuthor's email []: joeb@example.com\nYour Github user or organization name []: example\nBrief description of the project []: My CKAN theme\nList of keywords (separated by spaces) [CKAN]:\nDo you want to include code examples? [y/N]: y\n\nWritten: /srv/app/src_extensions/ckanext-mytheme\n```\n\nThe new extension files and directories are created in the `/srv/app/src_extensions/` folder in the running container. They will also exist in the local src/ directory as local `/src` directory is mounted as `/srv/app/src_extensions/` on the ckan container.\n\n\n#### Running HTTPS on development mode\n\nSometimes is useful to run your local development instance under HTTPS, for instance if you are using authentication extensions like [ckanext-saml2auth](https://github.com/keitaroinc/ckanext-saml2auth). To enable it, set the following in your `.env` file:\n\n```\n  USE_HTTPS_FOR_DEV=true\n```\n\nand update the site URL setting:\n\n```\n  CKAN_SITE_URL=https://localhost:5000\n```\n\nAfter recreating the `ckan-dev` container, you should be able to access CKAN at https://localhost:5000\n\n\n#### Remote Debugging with VS Code\n\n[Visual Studio Code](https://code.visualstudio.com/) is a free IDE that includes remote\ndebugging for Python applications. To debug CKAN you must enable `debugpy` for your\ndevelopment instance in your `.env` file:\n\n```\n  USE_DEBUGPY_FOR_DEV=true\n```\n\nNext run the install script to install debugpy:\n\n\tbin/install_src\n\nThen start the containers in [development mode](#development-mode) and launch VS Code.\n\nIn VS Code:\n\n1. Install the \"Dev Container\" extension: press CTRL+SHIFT+X, type \"dev container\", click \"install\"\n2. Click the \"Open a Remote Window\" button in the bottom-left of the VS Code window\n3. Click \"Attach to Running Container...\" and select your ckan-dev container, e.g. \"ckan-docker-ckan-dev-1\"\n4. Click the \"Run and Debug\" icon on the left panel and choose to install the \"Python Debugger\"\n5. Click \"create a launch.json\", select \"Python Debugger\", \"Remote Attach\", host \"localhost\" and port \"5678\"\n6. Press F5 or click the \"Run\" menu and \"Start Debugging\"\n\nYou can now set breakpoints and remote debug your CKAN development instance.\n\n\n#### Updating the environment file for development mode\n\nThe Docker Compose environment `.env` file by default is set up for production mode. There are a few changes needed if you would like to run in Development mode:\n\n1. Change the `CKAN_SITE_URL` variable to be: http://localhost:5000\n2. Update the `CKAN__DATAPUSHER__CALLBACK_URL_BASE` variable to use the `ckan-dev` container name: http://ckan-dev:5000\n\n\n## 5. CKAN images\n![ckan images](https://user-images.githubusercontent.com/54408245/207079416-a01235af-2dea-4425-b6fd-f8c3687dd993.png)\n\n\n\nThe Docker image config files used to build your CKAN project are located in the `ckan/` folder. There are two Docker files:\n\n* `Dockerfile`: this is based on `ckan/ckan-base:\u003cversion\u003e`, a base image located in the DockerHub repository, that has CKAN installed along with all its dependencies, properly configured and running on [uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/) (production setup)\n* `Dockerfile.dev`:  this is based on `ckan/ckan-base:\u003cversion\u003e-dev` also located located in the DockerHub repository, and extends `ckan/ckan-base:\u003cversion\u003e` to include:\n\n  * Any extension cloned on the `src` folder will be installed in the CKAN container when booting up Docker Compose (`docker compose up`). This includes installing any requirements listed in a `requirements.txt` (or `pip-requirements.txt`) file and running `python setup.py develop`.\n  * CKAN is started running this: `/usr/bin/ckan -c /srv/app/ckan.ini run -H 0.0.0.0`.\n  * Make sure to add the local plugins to the `CKAN__PLUGINS` env var in the `.env` file.\n\n* Any custom changes to the scripts run during container start up can be made to scripts in the `setup/` directory. For instance if you wanted to change the port on which CKAN runs you would need to make changes to the Docker Compose yaml file, and the `start_ckan.sh.override` file. Then you would need to add the following line to the Dockerfile ie: `COPY setup/start_ckan.sh.override ${APP_DIR}/start_ckan.sh`. The `start_ckan.sh` file in the locally built image would override the `start_ckan.sh` file included in the base image\n\n### Extending the base images\n\nThe CKAN base images are built from https://github.com/ckan/ckan-docker-base/\n\nYou can modify the docker files to build your own customized image tailored to your project, installing any extensions and extra requirements needed. For example here is where you would update to use a different CKAN base image ie: `ckan/ckan-base:\u003cnew version\u003e`\n\nTo perform extra initialization steps you can add scripts to your custom images and copy them to the `/docker-entrypoint.d` folder (The folder should be created for you when you build the image). Any `*.sh` and `*.py` file in that folder will be executed just after the main initialization script ([`prerun.py`](https://github.com/ckan/ckan-docker-base/blob/main/ckan-2.9/base/setup/prerun.py)) is executed and just before the web server and supervisor processes are started.\n\nFor instance, consider the following custom image:\n\n```\nckan\n├── docker-entrypoint.d\n│   └── setup_validation.sh\n├── Dockerfile\n└── Dockerfile.dev\n\n```\n\nWe want to install an extension like [ckanext-validation](https://github.com/frictionlessdata/ckanext-validation) that needs to create database tables on startup time. We create a `setup_validation.sh` script in a `docker-entrypoint.d` folder with the necessary commands:\n\n```bash\n#!/bin/bash\n\n# Create DB tables if not there\nckan -c /srv/app/ckan.ini validation init-db \n```\n\nAnd then in our `Dockerfile.dev` file we install the extension and copy the initialization scripts:\n\n```Dockerfile\nFROM ckan/ckan-base:2.9.7-dev\n\nRUN pip install -e git+https://github.com/frictionlessdata/ckanext-validation.git#egg=ckanext-validation \u0026\u0026 \\\n    pip install -r https://raw.githubusercontent.com/frictionlessdata/ckanext-validation/master/requirements.txt\n\nCOPY docker-entrypoint.d/* /docker-entrypoint.d/\n```\n\nNB: There are a number of extension examples commented out in the Dockerfile.dev file\n\n### Applying patches\n\nWhen building your project specific CKAN images (the ones defined in the `ckan/` folder), you can apply patches \nto CKAN core or any of the built extensions. To do so create a folder inside `ckan/patches` with the name of the\npackage to patch (ie `ckan` or `ckanext-??`). Inside you can place patch files that will be applied when building\nthe images. The patches will be applied in alphabetical order, so you can prefix them sequentially if necessary.\n\nFor instance, check the following example image folder:\n\n```\nckan\n├── patches\n│   ├── ckan\n│   │   ├── 01_datasets_per_page.patch\n│   │   ├── 02_groups_per_page.patch\n│   │   ├── 03_or_filters.patch\n│   └── ckanext-harvest\n│       └── 01_resubmit_objects.patch\n├── setup\n├── Dockerfile\n└── Dockerfile.dev\n\n```\n\n## 6. Debugging with pdb\n\nAdd these lines to the `ckan-dev` service in the docker-compose.dev.yml file\n\n```yaml\nstdin_open: true\ntty: true\n```\n\nDebug with pdb (example) - Interact with `docker attach $(docker container ls -qf name=ckan)`\n\ncommand: `python -m pdb /usr/lib/ckan/venv/bin/ckan --config /srv/app/ckan.ini run --host 0.0.0.0 --passthrough-errors`\n\n## 7. Datastore and datapusher\n\nThe Datastore database and user is created as part of the entrypoint scripts for the db container. There is also a Datapusher container \nrunning the latest version of Datapusher.\n\n## 8. NGINX\n\nThe base Docker Compose configuration uses an NGINX image as the front-end (ie: reverse proxy). It includes HTTPS running on port number 8443. A \"self-signed\" SSL certificate is generated as part of the ENTRYPOINT. The NGINX `server_name` directive and the `CN` field in the SSL certificate have been both set to 'localhost'. This should obviously not be used for production.\n\nCreating the SSL cert and key files as follows:\n`openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj \"/C=DE/ST=Berlin/L=Berlin/O=None/CN=localhost\" -keyout ckan-local.key -out ckan-local.crt`\nThe `ckan-local.*` files will then need to be moved into the nginx/setup/ directory\n\n## 9. ckanext-envvars\n\nThe ckanext-envvars extension is used in the CKAN Docker base repo to build the base images.\nThis extension checks for environmental variables conforming to an expected format and updates the corresponding CKAN config settings with its value.\n\nFor the extension to correctly identify which env var keys map to the format used for the config object, env var keys should be formatted in the following way:\n\n  All uppercase  \n  Replace periods ('.') with two underscores ('__')  \n  Keys must begin with 'CKAN' or 'CKANEXT', if they do not you can prepend them with '`CKAN___`' \n\nFor example:\n\n  * `CKAN__PLUGINS=\"envvars image_view text_view recline_view datastore datapusher\"`\n  * `CKAN__DATAPUSHER__CALLBACK_URL_BASE=http://ckan:5000`\n  * `CKAN___BEAKER__SESSION__SECRET=CHANGE_ME`\n\nThese parameters can be added to the `.env` file \n\nFor more information please see [ckanext-envvars](https://github.com/okfn/ckanext-envvars)\n\n## 10. CKAN_SITE_URL\n\nFor convenience the CKAN_SITE_URL parameter should be set in the .env file. For development it can be set to http://localhost:5000 and non-development set to https://localhost:8443\n\n## 11. Manage new users\n\n1. Create a new user from the Docker host, for example to create a new user called 'admin'\n\n   `docker compose exec ckan ckan user add admin email=admin@localhost`\n\n   To set this user as a sysadmin run\n\n   `docker compose exec ckan ckan sysadmin add admin`\n\n   To delete the 'admin' user\n\n   `docker compose exec ckan ckan user remove admin`\n\n   In development mode use `bin/ckan` instead of `docker compose exec ckan ckan` for the above commands.\n\n\n## 12. Changing the base image\n\nThe base image used in the CKAN Dockerfile and Dockerfile.dev can be changed so a different DockerHub image is used eg: ckan/ckan-base:2.10.5 can be used instead of ckan/ckan-base:2.11.0\n\n## 13. Replacing DataPusher with XLoader\n\nCheck out the wiki page for this: https://github.com/ckan/ckan-docker/wiki/Replacing-DataPusher-with-XLoader\n\nCopying and License\n-------------------\n\nThis material is copyright (c) 2006-2023 Open Knowledge Foundation and contributors.\n\nIt is open and licensed under the GNU Affero General Public License (AGPL) v3.0\nwhose full text may be found at:\n\nhttp://www.fsf.org/licensing/licenses/agpl-3.0.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckan%2Fckan-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckan%2Fckan-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckan%2Fckan-docker/lists"}