From faa3234773748553c7272f529f1078e6e1c8f0e9 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 16 Dec 2024 14:51:52 -0500 Subject: [PATCH 1/2] commands for working with dev --- README.md | 16 ++++++---------- bin/ckan | 6 ++++++ bin/compose | 6 ++++++ bin/generate_extension | 13 +++++++++++++ bin/install_src | 6 ++++++ bin/restart | 6 ++++++ bin/shell | 6 ++++++ 7 files changed, 49 insertions(+), 10 deletions(-) create mode 100755 bin/ckan create mode 100755 bin/compose create mode 100755 bin/generate_extension create mode 100755 bin/install_src create mode 100755 bin/restart create mode 100755 bin/shell 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..6c772ef2 --- /dev/null +++ b/bin/generate_extension @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +ROOT="$(dirname ${BASH_SOURCE[0]})/.." +USERGROUP="$(stat -c '%u:%g' "${ROOT}/src")" +if [ "$USERGROUP" == ":" ]; then + # macos stat? + USERGROUP="$(stat -f '%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 "$@" From d9a3540cdf904b1eb46b88b8fae99b94ded07fd5 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Wed, 18 Dec 2024 09:24:04 -0500 Subject: [PATCH 2/2] fix for macOS Co-authored-by: Brett Jones <54408245+kowh-ai@users.noreply.github.com> --- bin/generate_extension | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/generate_extension b/bin/generate_extension index 6c772ef2..83a239a1 100755 --- a/bin/generate_extension +++ b/bin/generate_extension @@ -2,10 +2,11 @@ set -e ROOT="$(dirname ${BASH_SOURCE[0]})/.." -USERGROUP="$(stat -c '%u:%g' "${ROOT}/src")" -if [ "$USERGROUP" == ":" ]; then - # macos stat? +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" \