Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands for working with dev container #198

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" "$@"
14 changes: 14 additions & 0 deletions bin/generate_extension
Original file line number Diff line number Diff line change
@@ -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 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 "$@"
Loading