From 60ebede32a69dc04a680d9dce03faa2d5d595316 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Wed, 18 Dec 2024 02:49:23 +0200 Subject: [PATCH] refactor: merge `dev-tools` into `wordpress` --- .github/dependabot.yml | 5 -- .github/workflows/dev-tools.yml | 50 ------------------- dev-tools/Dockerfile | 9 ---- dev-tools/add-site.sh | 47 ----------------- wordpress/.dockerignore | 3 +- wordpress/Dockerfile | 3 ++ .../dev-tools}/dev-env-plugin.php | 0 {dev-tools => wordpress/dev-tools}/setup.sh | 0 .../dev-tools}/wp-config-defaults.php | 0 .../dev-tools}/wp-config-multisite.php.tpl | 0 .../dev-tools}/wp-config.php.tpl | 0 .../scripts/user-container-setup.sh | 0 12 files changed, 5 insertions(+), 112 deletions(-) delete mode 100644 .github/workflows/dev-tools.yml delete mode 100644 dev-tools/Dockerfile delete mode 100755 dev-tools/add-site.sh rename {dev-tools => wordpress/dev-tools}/dev-env-plugin.php (100%) rename {dev-tools => wordpress/dev-tools}/setup.sh (100%) rename {dev-tools => wordpress/dev-tools}/wp-config-defaults.php (100%) rename {dev-tools => wordpress/dev-tools}/wp-config-multisite.php.tpl (100%) rename {dev-tools => wordpress/dev-tools}/wp-config.php.tpl (100%) rename {dev-tools => wordpress}/scripts/user-container-setup.sh (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 89938ffc..c1e416e9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,11 +15,6 @@ updates: schedule: interval: "weekly" - - package-ecosystem: "docker" - directory: "dev-tools/" - schedule: - interval: "weekly" - - package-ecosystem: "docker" directory: "helpers/" schedule: diff --git a/.github/workflows/dev-tools.yml b/.github/workflows/dev-tools.yml deleted file mode 100644 index 3f62396e..00000000 --- a/.github/workflows/dev-tools.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build Developer Tools - -on: - push: - branches: - - master - paths: - - "dev-tools/**" - - ".github/workflows/dev-tools.yml" - - ".github/actions/build-docker-image/**" - pull_request: - paths: - - "dev-tools/**" - - ".github/workflows/dev-tools.yml" - - ".github/actions/build-docker-image/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - push_to_registry: - name: Push Docker image to GitHub Packages - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - pull-requests: write - security-events: write - id-token: write - attestations: write - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Build and push image - uses: ./.github/actions/build-docker-image - with: - context: dev-tools - push: ${{ github.base_ref == null }} - no-cache: ${{ github.event_name == 'workflow_dispatch' }} - cache-from: type=gha,scope=dev-tools - cache-to: type=gha,mode=max,scope=dev-tools - primaryTag: ghcr.io/automattic/vip-container-images/dev-tools:0.9 - tags: ghcr.io/automattic/vip-container-images/dev-tools:0.9 - scan: false diff --git a/dev-tools/Dockerfile b/dev-tools/Dockerfile deleted file mode 100644 index fe500278..00000000 --- a/dev-tools/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM ghcr.io/automattic/vip-container-images/helpers:v1@sha256:bc2beca042ce7c47e2b737920c77248f4a6c25cc7e137bf9de6944af8a68701c AS helpers -FROM busybox:stable-musl@sha256:b4771ab006a5344931341972e1e4b1ff14db2c327eeab0053416aa2277213b1d - -COPY --from=helpers /rsync /usr/bin/rsync -COPY --link setup.sh add-site.sh dev-env-plugin.php wp-config* /dev-tools-orig/ -COPY --link setup.sh add-site.sh dev-env-plugin.php wp-config* /dev-tools/ -COPY --link scripts /scripts - -ENTRYPOINT ["/usr/bin/rsync", "-a", "--delete", "/dev-tools-orig/", "/dev-tools/"] diff --git a/dev-tools/add-site.sh b/dev-tools/add-site.sh deleted file mode 100755 index 9afadea6..00000000 --- a/dev-tools/add-site.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -syntax() { - echo "Syntax: add-site.sh --slug= --title=\"\"" - exit 1 -} - -# Parse title and slug arguments -arguments=$(getopt -o '' -l slug:,title: -- "$@") -eval set -- "$arguments" -while true; do - case "$1" in - --slug) slug=$2; shift 2;; - --title) title=$2; shift 2;; - --) shift; break;; - esac -done -[ -z "$slug" ] && echo "ERROR: Missing or empty slug argument" && syntax -[ -z "$title" ] && echo "ERROR: Missing or empty title argument" && syntax - -network_domain=$(wp --allow-root site list --field=domain --skip-plugins --skip-themes | head -n1) - -site_domain=$slug.$network_domain - -echo "Checking if this is a multisite installation..." -if ! wp --allow-root core is-installed --network --skip-plugins --skip-themes; then - echo "ERROR: Not a multisite" - exit 1 -fi - -echo "Checking if $site_domain already belongs to another site..." -if wp --allow-root --path=/wp site list --field=domain --skip-plugins --skip-themes | grep -q "^$site_domain$"; then - echo "ERROR: site with domain $site_domain already exists" - exit 1 -fi - -echo "Creating the new site..." -wp --allow-root --skip-plugins --skip-themes --path=/wp site create --title="$title" --slug="$slug" - -echo -echo "======================================================================" -echo "Site '$title' added correctly" -echo -echo "You can access it using these URLs:" -echo " http://$site_domain/" -echo " http://$site_domain/wp-admin/" -echo "======================================================================" diff --git a/wordpress/.dockerignore b/wordpress/.dockerignore index 9887b4b3..3d792b95 100644 --- a/wordpress/.dockerignore +++ b/wordpress/.dockerignore @@ -1,3 +1,4 @@ * -!entrypoint.sh +!dev-tools !extra +!scripts diff --git a/wordpress/Dockerfile b/wordpress/Dockerfile index ca3dd770..70b0c8cd 100644 --- a/wordpress/Dockerfile +++ b/wordpress/Dockerfile @@ -7,4 +7,7 @@ COPY extra/ /wp/ FROM ghcr.io/automattic/vip-container-images/helpers:v1@sha256:bc2beca042ce7c47e2b737920c77248f4a6c25cc7e137bf9de6944af8a68701c AS helpers FROM busybox:stable-musl@sha256:b4771ab006a5344931341972e1e4b1ff14db2c327eeab0053416aa2277213b1d COPY --from=build --link /wp /wp +COPY --link dev-tools /dev-tools +COPY --link dev-tools /dev-tools-orig +COPY --link scripts /scripts COPY --from=helpers /rsync /usr/bin/rsync diff --git a/dev-tools/dev-env-plugin.php b/wordpress/dev-tools/dev-env-plugin.php similarity index 100% rename from dev-tools/dev-env-plugin.php rename to wordpress/dev-tools/dev-env-plugin.php diff --git a/dev-tools/setup.sh b/wordpress/dev-tools/setup.sh similarity index 100% rename from dev-tools/setup.sh rename to wordpress/dev-tools/setup.sh diff --git a/dev-tools/wp-config-defaults.php b/wordpress/dev-tools/wp-config-defaults.php similarity index 100% rename from dev-tools/wp-config-defaults.php rename to wordpress/dev-tools/wp-config-defaults.php diff --git a/dev-tools/wp-config-multisite.php.tpl b/wordpress/dev-tools/wp-config-multisite.php.tpl similarity index 100% rename from dev-tools/wp-config-multisite.php.tpl rename to wordpress/dev-tools/wp-config-multisite.php.tpl diff --git a/dev-tools/wp-config.php.tpl b/wordpress/dev-tools/wp-config.php.tpl similarity index 100% rename from dev-tools/wp-config.php.tpl rename to wordpress/dev-tools/wp-config.php.tpl diff --git a/dev-tools/scripts/user-container-setup.sh b/wordpress/scripts/user-container-setup.sh similarity index 100% rename from dev-tools/scripts/user-container-setup.sh rename to wordpress/scripts/user-container-setup.sh