Merge pull request #198 from ckan/dev-bin-scripts

commands for working with dev container
This commit is contained in:
Brett Jones 2024-12-19 06:23:17 +01:00 committed by GitHub
commit 00a189030b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 50 additions and 10 deletions

View File

@ -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.

6
bin/ckan Executable file
View File

@ -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 "$@"

6
bin/compose Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
ROOT="$(dirname ${BASH_SOURCE[0]})/.."
docker compose -f "${ROOT}/docker-compose.dev.yml" "$@"

14
bin/generate_extension Executable file
View File

@ -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

6
bin/install_src Executable file
View File

@ -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

6
bin/restart Executable file
View File

@ -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

6
bin/shell Executable file
View File

@ -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 "$@"