From 56d492dd3e8fbdd53e6f9fe117bbc9ddcf287925 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 9 Sep 2024 15:31:29 +0200 Subject: [PATCH 1/4] Update Dockerfile and Dockerfile.dev --- ckan/Dockerfile | 6 ++++-- ckan/Dockerfile.dev | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ckan/Dockerfile b/ckan/Dockerfile index 67a431e..4f1032b 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -4,11 +4,13 @@ FROM ckan/ckan-base:2.11.0 # See Dockerfile.dev for more details and examples # Copy custom initialization scripts -COPY docker-entrypoint.d/* /docker-entrypoint.d/ +COPY --chown=ckan-sys:ckan-sys docker-entrypoint.d/* /docker-entrypoint.d/ # Apply any patches needed to CKAN core or any of the built extensions (not the # runtime mounted ones) -COPY patches ${APP_DIR}/patches +COPY --chown=ckan-sys:ckan-sys patches ${APP_DIR}/patches + +USER ckan RUN for d in $APP_DIR/patches/*; do \ if [ -d $d ]; then \ diff --git a/ckan/Dockerfile.dev b/ckan/Dockerfile.dev index a815507..d5419ba 100644 --- a/ckan/Dockerfile.dev +++ b/ckan/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM ckan/ckan-dev:2.11.0 +FROM ckan/ckan-dev:2.11.0-py3.10 # Install any extensions needed by your CKAN instance # - Make sure to add the plugins to CKAN__PLUGINS in the .env file @@ -35,11 +35,11 @@ FROM ckan/ckan-dev:2.11.0 # to get them mounted in this image at runtime # Copy custom initialization scripts -COPY docker-entrypoint.d/* /docker-entrypoint.d/ +COPY --chown=ckan-sys:ckan-sys docker-entrypoint.d/* /docker-entrypoint.d/ # Apply any patches needed to CKAN core or any of the built extensions (not the # runtime mounted ones) -COPY patches ${APP_DIR}/patches +COPY --chown=ckan-sys:ckan-sys patches ${APP_DIR}/patches RUN for d in $APP_DIR/patches/*; do \ if [ -d $d ]; then \ From ec2a680ba521fbe7a38012e6af1990a748a5eecb Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Thu, 7 Nov 2024 17:06:48 -0500 Subject: [PATCH 2/4] Cache correct paths for new images --- docker-compose.dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index de97cc1..8d722ac 100755 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -4,6 +4,7 @@ volumes: solr_data: pip_cache: site_packages: + local_bin: vscode_server: services: @@ -26,7 +27,8 @@ services: - ckan_storage:/var/lib/ckan - ./src:/srv/app/src_extensions - pip_cache:/root/.cache/pip - - site_packages:/usr/lib/python3.10/site-packages + - site_packages:/usr/local/lib/python3.10/site-packages + - local_bin:/usr/local/bin - vscode_server:/root/.vscode-server restart: unless-stopped healthcheck: From 4b9e58155beffaf611dac0fd39cf2c478c0985ef Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Thu, 7 Nov 2024 20:44:59 -0500 Subject: [PATCH 3/4] update readme for create and install extension commands --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3e2ab36..0720c59 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ To build the images: docker compose -f docker-compose.dev.yml build +To install extensions from the `src` directory: + + docker compose -f docker-compose.dev.yml run -u root ckan-dev ./install_src.sh + To start the containers: docker compose -f docker-compose.dev.yml up @@ -114,7 +118,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 ckan-dev ckan generate extension --output-dir /srv/app/src_extensions +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 ``` ``` @@ -131,12 +135,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. -The files will be owned by root, to correct the ownership so you can edit the files with your normal account outside the container run: - -```bash -docker compose -f docker-compose.dev.yml exec ckan-dev chown --reference /srv/app/src_extensions/ -R /srv/app/src_extensions/ckanext-mytheme/ -``` - #### Running HTTPS on development mode Sometimes is useful to run your local development instance under HTTPS, for instance if you are using authentication extensions like [ckanext-saml2auth](https://github.com/keitaroinc/ckanext-saml2auth). To enable it, set the following in your `.env` file: From a870d3a166441e5acbda57497144231e4dba02c0 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 13 Nov 2024 15:26:25 +0100 Subject: [PATCH 4/4] last commit --- README.md | 3 +++ ckan/Dockerfile | 2 +- ckan/Dockerfile.dev | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0720c59..09c50b5 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,9 @@ 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 Sometimes is useful to run your local development instance under HTTPS, for instance if you are using authentication extensions like [ckanext-saml2auth](https://github.com/keitaroinc/ckanext-saml2auth). To enable it, set the following in your `.env` file: diff --git a/ckan/Dockerfile b/ckan/Dockerfile index 4f1032b..17269f0 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -1,4 +1,4 @@ -FROM ckan/ckan-base:2.11.0 +FROM ckan/ckan-base:2.11 # Install any extensions needed by your CKAN instance # See Dockerfile.dev for more details and examples diff --git a/ckan/Dockerfile.dev b/ckan/Dockerfile.dev index d5419ba..b4a12b9 100644 --- a/ckan/Dockerfile.dev +++ b/ckan/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM ckan/ckan-dev:2.11.0-py3.10 +FROM ckan/ckan-dev:2.11 # Install any extensions needed by your CKAN instance # - Make sure to add the plugins to CKAN__PLUGINS in the .env file @@ -41,6 +41,8 @@ COPY --chown=ckan-sys:ckan-sys docker-entrypoint.d/* /docker-entrypoint.d/ # runtime mounted ones) COPY --chown=ckan-sys:ckan-sys patches ${APP_DIR}/patches +USER ckan + RUN for d in $APP_DIR/patches/*; do \ if [ -d $d ]; then \ for f in `ls $d/*.patch | sort -g`; do \