diff --git a/README.md b/README.md index 751dc010..8026304b 100644 --- a/README.md +++ b/README.md @@ -96,19 +96,19 @@ After this step, CKAN should be running at `CKAN_SITE_URL` (by default https://l 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. -To develop local extensions use the `docker-compose.dev.yml` file: +To develop local extensions use the `docker-compose.dev.yml` file with help from the scripts under `bin`: To build the images: - docker compose -f docker-compose.dev.yml build + bin/compose build To install extensions from the `src` directory: - docker compose -f docker-compose.dev.yml run -u root ckan-dev ./install_src.sh + bin/install_src To start the containers: - docker compose -f docker-compose.dev.yml up + bin/compose up See [CKAN images](#5-ckan-images) for more details of what happens when using development mode. @@ -117,9 +117,7 @@ See [CKAN images](#5-ckan-images) for more details of what happens when using de You 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: -```bash -docker compose -f docker-compose.dev.yml exec -u `stat -c '%u' src` -e HOME=/srv/app/src_extensions ckan-dev ckan generate extension --output-dir /srv/app/src_extensions -``` + bin/generate_extension ``` Extension's name [must begin 'ckanext-']: ckanext-mytheme @@ -135,8 +133,6 @@ Written: /srv/app/src_extensions/ckanext-mytheme The 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. -Please note that you will need to change the stat command to `stat -f '%u' src` on Mac OS rather than `stat -c '%u' src` which is specific to GNU stat (ie: Linux) - #### Running HTTPS on development mode @@ -167,7 +163,7 @@ development instance in your `.env` file: Next run the install script to install debugpy: - docker compose -f docker-compose.dev.yml run -u root ckan-dev ./install_src.sh + bin/install_src Then start the containers in [development mode](#development-mode) and launch VS Code. diff --git a/bin/ckan b/bin/ckan new file mode 100755 index 00000000..788fb10c --- /dev/null +++ b/bin/ckan @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." + +docker compose -f "${ROOT}/docker-compose.dev.yml" exec ckan-dev ckan "$@" diff --git a/bin/compose b/bin/compose new file mode 100755 index 00000000..c6cc383c --- /dev/null +++ b/bin/compose @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." + +docker compose -f "${ROOT}/docker-compose.dev.yml" "$@" diff --git a/bin/generate_extension b/bin/generate_extension new file mode 100755 index 00000000..83a239a1 --- /dev/null +++ b/bin/generate_extension @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." +if [[ "$(uname)" == "Darwin" ]]; then + # macOS + USERGROUP="$(stat -f '%u:%g' "${ROOT}/src")" +else + USERGROUP="$(stat -c '%u:%g' "${ROOT}/src")" +fi + +docker compose -f "${ROOT}/docker-compose.dev.yml" exec -u "$USERGROUP" \ + -e HOME=/srv/app/src_extensions ckan-dev ckan generate extension \ + --output-dir /srv/app/src_extensions diff --git a/bin/install_src b/bin/install_src new file mode 100755 index 00000000..49bbe6b5 --- /dev/null +++ b/bin/install_src @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." + +docker compose -f "${ROOT}/docker-compose.dev.yml" run -u root ckan-dev ./install_src.sh diff --git a/bin/restart b/bin/restart new file mode 100755 index 00000000..6cd16078 --- /dev/null +++ b/bin/restart @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." + +docker compose -f "${ROOT}/docker-compose.dev.yml" restart ckan-dev diff --git a/bin/shell b/bin/shell new file mode 100755 index 00000000..87a89f3b --- /dev/null +++ b/bin/shell @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." + +docker compose -f "${ROOT}/docker-compose.dev.yml" exec ckan-dev bash "$@"