Skip to content

Commit

Permalink
Update to LEAF 3.0.10 & enhance update process #6
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferya committed Aug 8, 2024
1 parent 33ce598 commit 69f0905
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 63 deletions.
105 changes: 57 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,72 +44,67 @@ The CWRC Repository customizations include Drupal modules and configurations tha

## Update

* update repository versions
* Update `docker-bake.hcl` variable `LEAF_VERSION` with the container tag from <https://gitlab.com/calincs/cwrc/leaf/leaf-base-i8>
* Check if local files have changed in <https://gitlab.com/calincs/cwrc/leaf/leaf-base-i8> since that last local update
* check `docker/drupal/rootfs` (the known files as of August 2024 are included in the following bullet points)
* `core.extension.yml` merge changes
* example using `sdiff` in interactive mode with `l` and `r` signifying how to manually merge the local CWRC customizations with the leaf-base changes
* ToDo: investigate using `yq` to automatically update the yaml like the json later in this process
* If not done then expect Drupal errors regarding missing modules

``` bash
$ sdiff -s -o /tmp/z ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
config_translation: 0 <
%l
> getjwtonlogin: 0
%r
> islandora_bagger_integration: 0
%r
locale: 0 <
%l
message: 0 <
message_notify: 0 <
%l
page_manager: 0 <
page_manager_ui: 0 <
%l
private_message: 0 <
private_message_notify: 0 <
%l
user_csv_import: 0 <
%l

$ diff /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
$ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
```
``` bash
$ sdiff -s -o /tmp/z ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
config_translation: 0 <
%l
> getjwtonlogin: 0
%r
> islandora_bagger_integration: 0
%r
locale: 0 <
%l
message: 0 <
message_notify: 0 <
%l
page_manager: 0 <
page_manager_ui: 0 <
%l
private_message: 0 <
private_message_notify: 0 <
%l
user_csv_import: 0 <
%l

$ diff /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
$ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
```

* `composer.json` & `composer.lock`

* copy from leaf-base
* `cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/`
* `cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.lock docker/drupal/rootfs/var/www/drupal/`
* add back CWRC customizations
* add Git repository manually in the `repositories` section of composer.json
* the CLI function has drawbacks: <https://jmichaelward.com/managing-composer-repositories-via-the-command-line/>
* `composer config -d docker/drupal/rootfs/var/www/drupal/ repositories.0 '{"type": "git","url": "https://github.com/cwrc/islandora_bagger_integration.git","no-api": true}'`

``` json
{
"type": "git",
"url": "https://github.com/cwrc/islandora_bagger_integration.git",
"no-api": true
},
```

* execute the helper to build the updated `composer.json` and `composer.lock` files
``` bash
cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/
cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.lock docker/drupal/rootfs/var/www/drupal/
```

* add back CWRC customizations
* The next step automatically adds the following via `jq` command
* updates composer.json
* updates composer.lock
* execute the helper to build the updated `composer.json` and `composer.lock` files

``` bash
docker buildx bake drupal-composer-helper --set "drupal.tags=ghcr.io/cwrc/drupal:local"
id=$(docker create "ghcr.io/cwrc/drupal:local")
docker cp $id:/var/www/drupal/composer.json /tmp/composer.json
docker cp $id:/var/www/drupal/composer.lock /tmp/composer.lock
docker cp $id:/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/
docker cp $id:/var/www/drupal/composer.lock /docker/drupal/rootfs/var/www/drupal/
docker rm -v $id
```

* review changes
* update repository versions

``` bash
cp /tmp/composer.lock docker/drupal/rootfs/var/www/drupal/
cp /tmp/composer.json docker/drupal/rootfs/var/www/drupal/
```
### Notes

* tried using sdiff on the composer.json/lock file but
* `composer.lock` doesn't like manual editing - `content-hash` is outdated
Expand All @@ -120,7 +115,21 @@ $ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml
$ mv /tmp/z docker/drupal/rootfs/var/www/drupal/composer.json
```
* tried using the composer tools to update `composer.json` and add CWRC custom Git repository in the `repositories` section of composer.json
* the `composer` CLI function has drawbacks: <https://jmichaelward.com/managing-composer-repositories-via-the-command-line/>
* `composer config -d docker/drupal/rootfs/var/www/drupal/ repositories.0 '{"type": "git","url": "https://github.com/cwrc/islandora_bagger_integration.git","no-api": true}'`
* the following needs to be added to the `composer.json`
``` json
{
"type": "git",
"url": "https://github.com/cwrc/islandora_bagger_integration.git",
"no-api": true
},
```
## Building a local image
* `docker buildx bake --set "drupal.tags=ghcr.io/cwrc/drupal:local"`
* `docker buildx bake --set "drupal.tags=ghcr.io/cwrc/drupal:local"`
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "REPOSITORY" {
# Not the one displayed on DockerHub.
# Variable names with '_TAG' and '_REPOSITORY' fail with docker/bake-action
variable "LEAF_VERSION" {
default = "3.0.8"
default = "3.0.10"
}
variable "LEAF_REGISTRY" {
default = "registry.gitlab.com/calincs/cwrc/leaf/leaf-base-i8"
Expand Down
9 changes: 2 additions & 7 deletions docker/drupal/Dockerfile-composer-helper
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ ARG TARGETARCH

# Copy local customizations
COPY --link rootfs /
COPY --link scripts /scripts/

# Add CWRC customizations to
# * composer.json
# * composer.lock
RUN --mount=type=cache,id=custom-drupal-composer-${TARGETARCH},sharing=locked,target=/root/.composer/cache \
bash /scripts/merge_cwrc_customizations.sh && \
composer require -d /var/www/drupal 'drupal/getjwtonlogin:^2.0' 'mjordan/islandora_bagger_integration' && \
#composer update -d /var/www/drupal 'drupal/getjwtonlogin:^2.0' 'mjordan/islandora_bagger_integration' && \
composer install -d /var/www/drupal && \
cleanup.sh

#RUN \
# cd /var/www/drupal && \
# grep getjwt * && \
# grep bag * \
# grep a
17 changes: 11 additions & 6 deletions docker/drupal/rootfs/var/www/drupal/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
"url": "https://github.com/mjordan/islandora_workbench_integration.git",
"no-api": true
},
{
"type": "git",
"url": "https://github.com/cwrc/islandora_bagger_integration.git",
"no-api": true
},
{
"type": "package",
"package": {
Expand Down Expand Up @@ -123,6 +118,11 @@
}
}
]
},
{
"type": "git",
"url": "https://github.com/cwrc/islandora_bagger_integration.git",
"no-api": true
}
],
"authors": [
Expand All @@ -148,6 +148,7 @@
"drupal/citation_select": "^1.0@beta",
"drupal/ckeditor": "^1.0",
"drupal/color": "^1.0",
"drupal/color_field": "^3.0",
"drupal/colorbox": "^2.0",
"drupal/condition_query": "^1.3",
"drupal/conditional_fields": "4.0.0-alpha5",
Expand Down Expand Up @@ -391,7 +392,8 @@
},
"drupal/core": {
"Parent menu exist check D10.2": "patches/core/parent_menu_exist.patch",
"PO file import error": "https://www.drupal.org/files/issues/2021-12-19/2449895_92.patch"
"PO file import error": "https://www.drupal.org/files/issues/2021-12-19/2449895_92.patch",
"Default value of selected options not working": "https://www.drupal.org/files/issues/2023-11-02/5220.patch"
},
"drupal/quickedit": {
"Uncaught TypeError: _.where & _.pluck is not a function": "https://www.drupal.org/files/issues/2023-12-27/type-error-where-pluck-not-a-function-3410956-3.patch"
Expand All @@ -411,6 +413,9 @@
},
"drupal/filefield_paths": {
"return value fix": "patches/getFromSupportedWidget.patch"
},
"drupal/layout_builder_perms": {
"Fix not valid context for entity context when editing the default layout entity types": "https://www.drupal.org/files/issues/2023-12-15/not_valid_context-3392780-reroll_patch_from_4-7_0.patch"
}
},
"drupal-core-project-message": {
Expand Down
66 changes: 65 additions & 1 deletion docker/drupal/rootfs/var/www/drupal/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module:
citation_select: 0
ckeditor: 0
color: 0
color_field: 0
colorbox: 0
comment: 0
conditional_fields: 0
Expand Down
18 changes: 18 additions & 0 deletions docker/drupal/scripts/merge_cwrc_customizations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

merge_composer_json() {
composer_json_path="/var/www/drupal/composer.json"
# append to .repositories[] the CWRC customization: islandora bagger to the list of repositories if it doesn't already exist
# could try an `jq` with `| has(.url)` and if/else to shorten this code
# jq 'if (.repositories[] | select(.url=="https://github.com/cwrc/islandora_bagger_integration.git") | has(.url)) then ${new_repo} else . end'
ret=$(jq -e '.repositories[] | select(.url=="https://github.com/cwrc/islandora_bagger_integration.git")' ${composer_json_path} >> /dev/null)
if [ $? == 0 ] ; then
echo "URL Found";
else
echo "URL Not Found";
jq '.repositories += [{"type": "git", "url": "https://github.com/cwrc/islandora_bagger_integration.git", "no-api": true}]' ${composer_json_path} > ${composer_json_path}.new && \
mv ${composer_json_path} ${composer_json_path}.bak && \
mv ${composer_json_path}.new ${composer_json_path}
fi
}

merge_composer_json

0 comments on commit 69f0905

Please sign in to comment.