From 6dbf2bb0b26624689e04d7d8da9cc20a85149207 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 8 Nov 2023 17:20:22 +0100 Subject: [PATCH 1/6] Adding build for testing images from devel. --- .github/workflows/ce-dev-build-dev.yml | 42 ++++++++++++++++++++++++++ docker-images/export.sh | 6 ++-- 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ce-dev-build-dev.yml diff --git a/.github/workflows/ce-dev-build-dev.yml b/.github/workflows/ce-dev-build-dev.yml new file mode 100644 index 0000000..952190b --- /dev/null +++ b/.github/workflows/ce-dev-build-dev.yml @@ -0,0 +1,42 @@ +name: Build the devel ce-dev base and controller images + +# Run this workflow only on a push/merged PR to branch devel +on: + push: + branches: + - devel + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: yarn + # Uses https://oclif.io/ + - name: Pack the JS + run: yarn oclif-dev pack + # We build mkcert from source because releases are broken + # The last step sets ce-dev config to NOT use sudo because this causes docker image push problems + - name: Install build and publish dependencies + run: | + sudo apt-get update + sudo apt-get install -y p7zip-full libnss3-tools wget + cd /tmp + wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz + export PATH=$PATH:/usr/local/go/bin + git clone https://github.com/FiloSottile/mkcert && cd mkcert + go build -ldflags "-X main.Version=$(git describe --tags)" + sudo mv ./mkcert /usr/local/bin && cd ../ + sudo chmod +x /usr/local/bin/mkcert + rm -Rf mkcert + mkdir -p ~/.config/ce-dev + touch ~/.config/ce-dev/preferences-1.x.yml + echo 'docker_bin: docker' > ~/.config/ce-dev/preferences-1.x.yml + echo 'docker_compose_bin: docker compose' >> ~/.config/ce-dev/preferences-1.x.yml + echo 'mkcert_bin: mkcert' >> ~/.config/ce-dev/preferences-1.x.yml + - name: Build and push Docker images + run: | + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + /bin/sh docker-images/export.sh devel --push diff --git a/docker-images/export.sh b/docker-images/export.sh index 7204c30..80f1ea6 100755 --- a/docker-images/export.sh +++ b/docker-images/export.sh @@ -27,7 +27,7 @@ fi OWN_DIR=$( cd "$( dirname "$OWN" )" && pwd -P) # Ensure we have a fresh image to start with. -docker image pull debian:buster +docker image pull debian:bullseye-slim # Build base image. echo "Building base image." @@ -45,8 +45,8 @@ if [ "$2" = "--push" ]; then docker image push "codeenigma/ce-dev-controller-1.x:$1" fi -# Build dind image. -# echo "Building dind image" +# Build DinD (Docker in Docker) image. +# echo "Building DinD image" # sudo docker image build --compress "--label=ce-dev-dind-1.x:$1" --no-cache=true -t "codeenigma/ce-dev-dind-1.x:$1" "$OWN_DIR/dind" || exit 1 # if [ "$2" = "--push" ]; then # echo "Publishing the image with docker image push codeenigma/ce-dev-dind-1.x:$1" From d3393a386c4f6b7b44b70e1c038eff65f9eadbc6 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 2 Jul 2024 17:21:53 +0200 Subject: [PATCH 2/6] Fixing vars formatting and adding PHP-FPM support for xdebug. --- .../drupal10/ce-dev/ansible/provision.yml.j2 | 105 +++++++++--------- .../drupal8/ce-dev/ansible/provision.yml.j2 | 93 ++++++++-------- .../drupal9/ce-dev/ansible/provision.yml.j2 | 105 +++++++++--------- 3 files changed, 153 insertions(+), 150 deletions(-) diff --git a/templates/drupal10/ce-dev/ansible/provision.yml.j2 b/templates/drupal10/ce-dev/ansible/provision.yml.j2 index 44a7fc1..3d55152 100644 --- a/templates/drupal10/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal10/ce-dev/ansible/provision.yml.j2 @@ -1,59 +1,60 @@ - hosts: {{ project_name }}-web become: true vars: - - _domain_name: www.{{ project_name }}.local - - _env_type: dev - - project_name: {{ project_name }} - - rkhunter: - allow_ssh_root_user: prohibit-password - - mysql_client: - host: {{ project_name }}-db - user: root - password: ce-dev + _domain_name: www.{{ project_name }}.local + _env_type: dev + project_name: {{ project_name }} + rkhunter: + allow_ssh_root_user: prohibit-password + mysql_client: + host: {{ project_name }}-db + user: root + password: ce-dev {% raw %} - - nginx: - domains: - - server_name: "{{ _domain_name }}" - access_log: "/var/log/nginx-access.log" - error_log: "/var/log/nginx-error.log" - error_log_level: "notice" - webroot: "/home/ce-dev/deploy/live.local/web" - project_type: "drupal8" - ssl: - domain: "{{ _domain_name }}" - cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" - key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" - handling: "unmanaged" - ratelimitingcrawlers: false - is_default: true - servers: - - port: 80 - ssl: false - https_redirect: true - - port: 443 - ssl: true - https_redirect: false - upstreams: [] - - php: - version: - - 8.1 - cli: - memory_limit: -1 - _env_type: dev - fpm: - _env_type: dev - - php_composer: - version: '' - version_branch: '--2' - keep_updated: true - - xdebug: - cli: true - - lhci: - enable_vnc: true - - nodejs: - version: 18.x - - apt_unattended_upgrades: - enable: false + nginx: + domains: + - server_name: "{{ _domain_name }}" + access_log: "/var/log/nginx-access.log" + error_log: "/var/log/nginx-error.log" + error_log_level: "notice" + webroot: "/home/ce-dev/deploy/live.local/web" + project_type: "drupal8" + ssl: + domain: "{{ _domain_name }}" + cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" + key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" + handling: "unmanaged" + ratelimitingcrawlers: false + is_default: true + servers: + - port: 80 + ssl: false + https_redirect: true + - port: 443 + ssl: true + https_redirect: false + upstreams: [] + php: + version: + - 8.1 + cli: + memory_limit: -1 + _env_type: dev + fpm: + _env_type: dev + php_composer: + version: '' + version_branch: '--2' + keep_updated: true + xdebug: + cli: true + fpm: true + lhci: + enable_vnc: true + nodejs: + version: 18.x + apt_unattended_upgrades: + enable: false {% endraw %} tasks: - ansible.builtin.apt: diff --git a/templates/drupal8/ce-dev/ansible/provision.yml.j2 b/templates/drupal8/ce-dev/ansible/provision.yml.j2 index f88fe05..a7c6078 100644 --- a/templates/drupal8/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/provision.yml.j2 @@ -1,53 +1,54 @@ - hosts: {{ project_name }}-web become: true vars: - - _domain_name: www.{{ project_name }}.local - - _env_type: dev - - project_name: {{ project_name }} - - rkhunter: - allow_ssh_root_user: prohibit-password - - mysql_client: - host: {{ project_name }}-db - user: root - password: ce-dev + _domain_name: www.{{ project_name }}.local + _env_type: dev + project_name: {{ project_name }} + rkhunter: + allow_ssh_root_user: prohibit-password + mysql_client: + host: {{ project_name }}-db + user: root + password: ce-dev {% raw %} - - nginx: - domains: - - server_name: "{{ _domain_name }}" - access_log: "/var/log/nginx-access.log" - error_log: "/var/log/nginx-error.log" - error_log_level: "notice" - webroot: "/home/ce-dev/deploy/live.local/web" - project_type: "drupal8" - ssl: - domain: "{{ _domain_name }}" - cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" - key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" - handling: "unmanaged" - ratelimitingcrawlers: false - is_default: true - servers: - - port: 80 - ssl: false - https_redirect: true - - port: 443 - ssl: true - https_redirect: false - upstreams: [] - - php: - version: - - 7.4 - cli: - memory_limit: -1 - _env_type: dev - fpm: - _env_type: dev - - xdebug: - cli: true - - lhci: - enable_vnc: true - - apt_unattended_upgrades: - enable: false + nginx: + domains: + - server_name: "{{ _domain_name }}" + access_log: "/var/log/nginx-access.log" + error_log: "/var/log/nginx-error.log" + error_log_level: "notice" + webroot: "/home/ce-dev/deploy/live.local/web" + project_type: "drupal8" + ssl: + domain: "{{ _domain_name }}" + cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" + key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" + handling: "unmanaged" + ratelimitingcrawlers: false + is_default: true + servers: + - port: 80 + ssl: false + https_redirect: true + - port: 443 + ssl: true + https_redirect: false + upstreams: [] + php: + version: + - 7.4 + cli: + memory_limit: -1 + _env_type: dev + fpm: + _env_type: dev + xdebug: + cli: true + fpm: true + lhci: + enable_vnc: true + apt_unattended_upgrades: + enable: false {% endraw %} tasks: - ansible.builtin.apt: diff --git a/templates/drupal9/ce-dev/ansible/provision.yml.j2 b/templates/drupal9/ce-dev/ansible/provision.yml.j2 index 635d39a..acee977 100644 --- a/templates/drupal9/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal9/ce-dev/ansible/provision.yml.j2 @@ -1,59 +1,60 @@ - hosts: {{ project_name }}-web become: true vars: - - _domain_name: www.{{ project_name }}.local - - _env_type: dev - - project_name: {{ project_name }} - - rkhunter: - allow_ssh_root_user: prohibit-password - - mysql_client: - host: {{ project_name }}-db - user: root - password: ce-dev + _domain_name: www.{{ project_name }}.local + _env_type: dev + project_name: {{ project_name }} + rkhunter: + allow_ssh_root_user: prohibit-password + mysql_client: + host: {{ project_name }}-db + user: root + password: ce-dev {% raw %} - - nginx: - domains: - - server_name: "{{ _domain_name }}" - access_log: "/var/log/nginx-access.log" - error_log: "/var/log/nginx-error.log" - error_log_level: "notice" - webroot: "/home/ce-dev/deploy/live.local/web" - project_type: "drupal8" - ssl: - domain: "{{ _domain_name }}" - cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" - key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" - handling: "unmanaged" - ratelimitingcrawlers: false - is_default: true - servers: - - port: 80 - ssl: false - https_redirect: true - - port: 443 - ssl: true - https_redirect: false - upstreams: [] - - php: - version: - - 8.0 - cli: - memory_limit: -1 - _env_type: dev - fpm: - _env_type: dev - - php_composer: - version: '' - version_branch: '--2' - keep_updated: true - - xdebug: - cli: true - - lhci: - enable_vnc: true - - nodejs: - version: 16.x - - apt_unattended_upgrades: - enable: false + nginx: + domains: + - server_name: "{{ _domain_name }}" + access_log: "/var/log/nginx-access.log" + error_log: "/var/log/nginx-error.log" + error_log_level: "notice" + webroot: "/home/ce-dev/deploy/live.local/web" + project_type: "drupal8" + ssl: + domain: "{{ _domain_name }}" + cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" + key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" + handling: "unmanaged" + ratelimitingcrawlers: false + is_default: true + servers: + - port: 80 + ssl: false + https_redirect: true + - port: 443 + ssl: true + https_redirect: false + upstreams: [] + php: + version: + - 8.0 + cli: + memory_limit: -1 + _env_type: dev + fpm: + _env_type: dev + php_composer: + version: '' + version_branch: '--2' + keep_updated: true + xdebug: + cli: true + fpm: true + lhci: + enable_vnc: true + nodejs: + version: 16.x + apt_unattended_upgrades: + enable: false {% endraw %} tasks: - ansible.builtin.apt: From d5cfef216ca484f2f7c8d15ff1d2eec5a6c3c3b5 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Fri, 9 Aug 2024 13:07:39 +0200 Subject: [PATCH 3/6] Supporting ability to pass a string of project types to build. --- templates/prebuild.sh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/templates/prebuild.sh b/templates/prebuild.sh index 29739fe..11f054c 100644 --- a/templates/prebuild.sh +++ b/templates/prebuild.sh @@ -1,7 +1,43 @@ #!/bin/sh # Test project creation and pre-build image. set -e + +usage(){ + echo 'prebuild.sh [OPTIONS]' + echo 'Test project creation and pre-build Docker images.' + echo '' + echo 'Available options:' + echo '--projects: space separated string of project types to build, defaults to all' + echo '--push: push images to the Docker registry' + echo '' +} + +# Parse options arguments. +parse_options(){ + while [ "${1:-}" ]; do + case "$1" in + "--projects") + shift + PROJECTS="$1" + ;; + "--push") + PUSH="true" + ;; + *) + usage + exit 1 + ;; + esac + shift + done +} + +# Set default variables. PROJECTS="blank drupal8 drupal9 drupal10" +PUSH="false" + +# Parse options. +parse_options "$@" # Common processing. OWN_DIR=$(dirname "$0") @@ -55,7 +91,7 @@ for PROJECT in $PROJECTS; do create_project "$PROJECT" test_project "$PROJECT" build_project "$PROJECT" - if [ -n "$1" ] && [ "$1" = "--push" ]; then + if [ "$PUSH" = "true" ]; then push_project "$PROJECT" fi done From 278ec295f83e15f3f4a42a1438dfaa0fb8f25cdb Mon Sep 17 00:00:00 2001 From: gregharvey Date: Fri, 9 Aug 2024 13:08:12 +0200 Subject: [PATCH 4/6] Updating GitHub Actions to split Drupal tests over two jobs. --- .github/workflows/ce-dev-test.yml | 36 +++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ce-dev-test.yml b/.github/workflows/ce-dev-test.yml index 6258ef4..2db31bc 100644 --- a/.github/workflows/ce-dev-test.yml +++ b/.github/workflows/ce-dev-test.yml @@ -6,7 +6,7 @@ on: - cron: '30 3 * * *' jobs: - build: + build-drupal9: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -36,4 +36,36 @@ jobs: run: | /bin/sh docker-images/export.sh --version latest --image-name ce-dev --dockerfile-path base /bin/sh docker-images/export.sh --version latest --image-name ce-dev-controller --dockerfile-path controller - /bin/sh templates/prebuild.sh + /bin/sh templates/prebuild.sh --projects "blank drupal9" + + build-drupal10: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + ref: '1.x' + - name: Install modules + run: yarn + # Uses https://oclif.io/ + # Not strictly necessary here, but ensures the packing works + - name: Pack the JS + run: yarn oclif-dev pack + # We build mkcert from source because releases are broken + - name: Install test dependencies + run: | + sudo apt-get update + sudo apt-get install -y p7zip-full libnss3-tools wget + cd /tmp + wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz + export PATH=$PATH:/usr/local/go/bin + git clone https://github.com/FiloSottile/mkcert && cd mkcert + go build -ldflags "-X main.Version=$(git describe --tags)" + sudo mv ./mkcert /usr/local/bin && cd ../ + sudo chmod +x /usr/local/bin/mkcert + rm -Rf mkcert + - name: Build and test + run: | + /bin/sh docker-images/export.sh --version latest --image-name ce-dev --dockerfile-path base + /bin/sh docker-images/export.sh --version latest --image-name ce-dev-controller --dockerfile-path controller + /bin/sh templates/prebuild.sh --projects drupal10 \ No newline at end of file From a3e4db467f17cd21a22a8c85e70d66c2715d15d6 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Fri, 9 Aug 2024 13:22:30 +0200 Subject: [PATCH 5/6] Upgrading GitHub Actions Ubuntu version. --- .github/workflows/ce-dev-PR-test.yml | 2 +- .github/workflows/ce-dev-build.yml | 2 +- .github/workflows/ce-dev-publish-docs.yml | 2 +- .github/workflows/ce-dev-test.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ce-dev-PR-test.yml b/.github/workflows/ce-dev-PR-test.yml index fefc9b2..7ff4137 100644 --- a/.github/workflows/ce-dev-PR-test.yml +++ b/.github/workflows/ce-dev-PR-test.yml @@ -5,7 +5,7 @@ on: pull_request jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install modules diff --git a/.github/workflows/ce-dev-build.yml b/.github/workflows/ce-dev-build.yml index 5bed936..6930607 100644 --- a/.github/workflows/ce-dev-build.yml +++ b/.github/workflows/ce-dev-build.yml @@ -11,7 +11,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install modules diff --git a/.github/workflows/ce-dev-publish-docs.yml b/.github/workflows/ce-dev-publish-docs.yml index d7c0b3f..265c944 100644 --- a/.github/workflows/ce-dev-publish-docs.yml +++ b/.github/workflows/ce-dev-publish-docs.yml @@ -13,7 +13,7 @@ jobs: # Name the Job name: Publish documentation # Set the type of machine to run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: # Configures global Git variables for committing diff --git a/.github/workflows/ce-dev-test.yml b/.github/workflows/ce-dev-test.yml index 2db31bc..abe1397 100644 --- a/.github/workflows/ce-dev-test.yml +++ b/.github/workflows/ce-dev-test.yml @@ -7,7 +7,7 @@ on: jobs: build-drupal9: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: @@ -39,7 +39,7 @@ jobs: /bin/sh templates/prebuild.sh --projects "blank drupal9" build-drupal10: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: From f8626503de0827e3a500bd98a00608b5ebf897f8 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Fri, 9 Aug 2024 13:23:54 +0200 Subject: [PATCH 6/6] Fixing EOF. --- .github/workflows/ce-dev-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ce-dev-test.yml b/.github/workflows/ce-dev-test.yml index abe1397..81aa1e1 100644 --- a/.github/workflows/ce-dev-test.yml +++ b/.github/workflows/ce-dev-test.yml @@ -68,4 +68,4 @@ jobs: run: | /bin/sh docker-images/export.sh --version latest --image-name ce-dev --dockerfile-path base /bin/sh docker-images/export.sh --version latest --image-name ce-dev-controller --dockerfile-path controller - /bin/sh templates/prebuild.sh --projects drupal10 \ No newline at end of file + /bin/sh templates/prebuild.sh --projects drupal10