From ff280c50f70f65d11d59eaddb926a7f49c5e0b07 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 10 Jan 2024 00:14:42 +0700 Subject: [PATCH] Add wp-cli config and entrypoint (#2) --- .github/workflows/wp.yml | 35 +++++++++++++---------------------- wp/php7.4/Dockerfile | 14 ++++++-------- wp/php7.4/wp-cli.yml | 1 - wp/php8.0/Dockerfile | 14 ++++++-------- wp/php8.0/wp-cli.yml | 1 - wp/php8.1/Dockerfile | 14 ++++++-------- wp/php8.1/wp-cli.yml | 1 - wp/php8.2/Dockerfile | 14 ++++++-------- wp/php8.2/wp-cli.yml | 1 - 9 files changed, 37 insertions(+), 58 deletions(-) delete mode 100644 wp/php7.4/wp-cli.yml delete mode 100644 wp/php8.0/wp-cli.yml delete mode 100644 wp/php8.1/wp-cli.yml delete mode 100644 wp/php8.2/wp-cli.yml diff --git a/.github/workflows/wp.yml b/.github/workflows/wp.yml index f4a91de..7be630d 100644 --- a/.github/workflows/wp.yml +++ b/.github/workflows/wp.yml @@ -27,7 +27,7 @@ jobs: version: ["7.4", "8.0", "8.1", "8.2"] env: - IMAGE_PATH: ./wp/php${{ matrix.version }} + IMAGE_CONTEXT: ./wp/php${{ matrix.version }} IMAGE_FILE: ./wp/php${{ matrix.version }}/Dockerfile IMAGE_REGISTRY: ghcr.io IMAGE_TAG: ghcr.io/${{ github.repository_owner }}/wp:php${{ matrix.version }}-fpm @@ -49,13 +49,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and export + - name: Extract metadata (tags, labels) for Docker + id: metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_TAG }} + + - name: Build and push uses: docker/build-push-action@v5 with: - context: . - load: true + provenance: false + push: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }} + context: ${{ env.IMAGE_CONTEXT }} file: ${{ env.IMAGE_FILE }} tags: ${{ env.IMAGE_TAG }} + labels: ${{ steps.metadata.outputs.labels }} + platforms: linux/amd64,linux/arm64 - name: Test run image run: | @@ -67,21 +76,3 @@ jobs: else exit 1; fi - - - name: Extract metadata (tags, labels) for Docker - id: metadata - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE_TAG }} - - - name: Build and push - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 - with: - context: ${{ env.IMAGE_PATH }} - push: true - provenance: false - file: ${{ env.IMAGE_FILE }} - tags: ${{ env.IMAGE_TAG }} - labels: ${{ steps.metadata.outputs.labels }} - platforms: linux/amd64,linux/arm64 diff --git a/wp/php7.4/Dockerfile b/wp/php7.4/Dockerfile index a366f50..39cf670 100644 --- a/wp/php7.4/Dockerfile +++ b/wp/php7.4/Dockerfile @@ -18,21 +18,19 @@ RUN docker-php-serversideup-dep-install-debian 'ghostscript default-mysql-client RUN install-php-extensions 'mysqli'; \ php -m; +COPY --chmod=755 entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh +COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ + RUN set -eux; \ mkdir -p /var/www/html; \ chown -R www-data:www-data /var/www/html -COPY --chmod=755 ./entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh -COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ - RUN set -eux; \ chmod +x /usr/local/bin/wp; \ mkdir -p /var/www/.wp-cli; \ - chown -R www-data:www-data /var/www/.wp-cli; - -COPY --chmod=644 --chown=www-data:www-data ./wp-cli.yml /var/www/.wp-cli/config.yml - -RUN wp cli info; + echo "path: /var/www/html" > /var/www/.wp-cli/config.yml; \ + chown -R www-data:www-data /var/www/.wp-cli; \ + wp cli info; RUN set -eux; \ apt-get update; \ diff --git a/wp/php7.4/wp-cli.yml b/wp/php7.4/wp-cli.yml deleted file mode 100644 index f0851a0..0000000 --- a/wp/php7.4/wp-cli.yml +++ /dev/null @@ -1 +0,0 @@ -path: /var/www/html diff --git a/wp/php8.0/Dockerfile b/wp/php8.0/Dockerfile index 1e21f0b..e41e181 100644 --- a/wp/php8.0/Dockerfile +++ b/wp/php8.0/Dockerfile @@ -18,21 +18,19 @@ RUN docker-php-serversideup-dep-install-debian 'ghostscript default-mysql-client RUN install-php-extensions 'mysqli'; \ php -m; +COPY --chmod=755 entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh +COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ + RUN set -eux; \ mkdir -p /var/www/html; \ chown -R www-data:www-data /var/www/html -COPY --chmod=755 ./entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh -COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ - RUN set -eux; \ chmod +x /usr/local/bin/wp; \ mkdir -p /var/www/.wp-cli; \ - chown -R www-data:www-data /var/www/.wp-cli; - -COPY --chmod=644 --chown=www-data:www-data ./wp-cli.yml /var/www/.wp-cli/config.yml - -RUN wp cli info; + echo "path: /var/www/html" > /var/www/.wp-cli/config.yml; \ + chown -R www-data:www-data /var/www/.wp-cli; \ + wp cli info; RUN set -eux; \ apt-get update; \ diff --git a/wp/php8.0/wp-cli.yml b/wp/php8.0/wp-cli.yml deleted file mode 100644 index f0851a0..0000000 --- a/wp/php8.0/wp-cli.yml +++ /dev/null @@ -1 +0,0 @@ -path: /var/www/html diff --git a/wp/php8.1/Dockerfile b/wp/php8.1/Dockerfile index 8efa006..961033c 100644 --- a/wp/php8.1/Dockerfile +++ b/wp/php8.1/Dockerfile @@ -18,21 +18,19 @@ RUN docker-php-serversideup-dep-install-debian 'ghostscript default-mysql-client RUN install-php-extensions 'mysqli'; \ php -m; +COPY --chmod=755 entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh +COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ + RUN set -eux; \ mkdir -p /var/www/html; \ chown -R www-data:www-data /var/www/html -COPY --chmod=755 ./entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh -COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ - RUN set -eux; \ chmod +x /usr/local/bin/wp; \ mkdir -p /var/www/.wp-cli; \ - chown -R www-data:www-data /var/www/.wp-cli; - -COPY --chmod=644 --chown=www-data:www-data ./wp-cli.yml /var/www/.wp-cli/config.yml - -RUN wp cli info; + echo "path: /var/www/html" > /var/www/.wp-cli/config.yml; \ + chown -R www-data:www-data /var/www/.wp-cli; \ + wp cli info; RUN set -eux; \ apt-get update; \ diff --git a/wp/php8.1/wp-cli.yml b/wp/php8.1/wp-cli.yml deleted file mode 100644 index f0851a0..0000000 --- a/wp/php8.1/wp-cli.yml +++ /dev/null @@ -1 +0,0 @@ -path: /var/www/html diff --git a/wp/php8.2/Dockerfile b/wp/php8.2/Dockerfile index 6f21b8b..92a89c4 100644 --- a/wp/php8.2/Dockerfile +++ b/wp/php8.2/Dockerfile @@ -18,21 +18,19 @@ RUN docker-php-serversideup-dep-install-debian 'ghostscript default-mysql-client RUN install-php-extensions 'mysqli'; \ php -m; +COPY --chmod=755 entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh +COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ + RUN set -eux; \ mkdir -p /var/www/html; \ chown -R www-data:www-data /var/www/html -COPY --chmod=755 ./entrypoint.sh /etc/entrypoint.d/70-wp-core-download.sh -COPY --from=wp-cli /usr/local/bin/wp /usr/local/bin/ - RUN set -eux; \ chmod +x /usr/local/bin/wp; \ mkdir -p /var/www/.wp-cli; \ - chown -R www-data:www-data /var/www/.wp-cli; - -COPY --chmod=644 --chown=www-data:www-data ./wp-cli.yml /var/www/.wp-cli/config.yml - -RUN wp cli info; + echo "path: /var/www/html" > /var/www/.wp-cli/config.yml; \ + chown -R www-data:www-data /var/www/.wp-cli; \ + wp cli info; RUN set -eux; \ apt-get update; \ diff --git a/wp/php8.2/wp-cli.yml b/wp/php8.2/wp-cli.yml deleted file mode 100644 index f0851a0..0000000 --- a/wp/php8.2/wp-cli.yml +++ /dev/null @@ -1 +0,0 @@ -path: /var/www/html