Skip to content

Commit

Permalink
commands for working with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Dec 16, 2024
1 parent 31e39c8 commit faa3234
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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

Expand Down Expand Up @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions bin/ckan
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions bin/compose
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e
ROOT="$(dirname ${BASH_SOURCE[0]})/.."

docker compose -f "${ROOT}/docker-compose.dev.yml" "$@"
13 changes: 13 additions & 0 deletions bin/generate_extension
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions bin/install_src
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions bin/restart
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions bin/shell
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit faa3234

Please sign in to comment.