Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG VERSION_WORDPRESS
ARG VERSION_PHP
FROM wordpress:${VERSION_WORDPRESS}-php${VERSION_PHP}-fpm
ARG WORDPRESS_BASE_IMAGE=wordpress:${VERSION_WORDPRESS}-php${VERSION_PHP}-fpm
FROM ${WORDPRESS_BASE_IMAGE}

Check warning on line 4 in .docker/wordpress/Dockerfile

View workflow job for this annotation

GitHub Actions / Build and push image

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ${WORDPRESS_BASE_IMAGE} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

RUN apt-get update
RUN apt-get install -y \
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: Docker WordPress Publish

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
inputs:
wordpress_base_image:
description: 'Override the official WordPress base image (version and PHP series)'
required: false
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -17,8 +23,7 @@ jobs:
name: Build and push image
runs-on: ubuntu-latest
env:
VERSION_WORDPRESS: "7.1.3"
VERSION_PHP: "8.3"
WORDPRESS_BASE_IMAGE: wordpress:7.1.3-php8.3-fpm@sha256:788d6b34cb89997483ff2a08e2e04d1df28ce284ca046cd7990b0be10828c5b9
permissions:
contents: read
packages: write
Expand All @@ -42,6 +47,7 @@ jobs:
wordpress-buildx-

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -54,10 +60,10 @@ jobs:
context: .docker/wordpress
file: .docker/wordpress/Dockerfile
platforms: linux/amd64,linux/arm64
pull: true
push: false
build-args: |
VERSION_WORDPRESS=${{ env.VERSION_WORDPRESS }}
VERSION_PHP=${{ env.VERSION_PHP }}
WORDPRESS_BASE_IMAGE=${{ inputs.wordpress_base_image || env.WORDPRESS_BASE_IMAGE }}
tags: |
ghcr.io/librecodecoop/wordpress-docker:${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
Expand All @@ -70,10 +76,10 @@ jobs:
context: .docker/wordpress
file: .docker/wordpress/Dockerfile
platforms: linux/amd64,linux/arm64
pull: true
push: true
build-args: |
VERSION_WORDPRESS=${{ env.VERSION_WORDPRESS }}
VERSION_PHP=${{ env.VERSION_PHP }}
WORDPRESS_BASE_IMAGE=${{ inputs.wordpress_base_image || env.WORDPRESS_BASE_IMAGE }}
tags: |
ghcr.io/librecodecoop/wordpress-docker:${{ github.sha }}
ghcr.io/librecodecoop/wordpress-docker:latest
Expand Down
2 changes: 1 addition & 1 deletion common-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
# build:
# context: .docker/wordpress
# args:
# VERSION_WORDPRESS: ${VERSION_WORDPRESS:-6.9}
# VERSION_WORDPRESS: ${VERSION_WORDPRESS:-7.1.3}
# VERSION_PHP: ${VERSION_PHP:-8.3}
restart: unless-stopped
volumes:
Expand Down
37 changes: 37 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"enabledManagers": [
"custom.regex"
],
"dependencyDashboard": false,
"separateMinorPatch": true,
"customManagers": [
{
"customType": "regex",
"managerFilePatterns": [
"/^\\.github\\/workflows\\/docker-publish\\.yml$/"
],
"matchStrings": [
"WORDPRESS_BASE_IMAGE: wordpress:(?<currentValue>\\d+\\.\\d+\\.\\d+-php\\d+\\.\\d+-fpm)@(?<currentDigest>sha256:[a-f0-9]{64})"
],
"datasourceTemplate": "docker",
"depNameTemplate": "wordpress",
"versioningTemplate": "docker"
}
],
"packageRules": [
{
"matchManagers": [
"custom.regex"
],
"matchPackageNames": [
"wordpress"
],
"matchUpdateTypes": [
"major",
"minor"
],
"enabled": false
}
]
}
22 changes: 22 additions & 0 deletions tests/security/image-version-selection.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bats

setup() {
cd "$BATS_TEST_DIRNAME/../.."
}

@test "WordPress and PHP versions remain selectable" {
grep -Fxq 'ARG VERSION_WORDPRESS' .docker/wordpress/Dockerfile
grep -Fxq 'ARG VERSION_PHP' .docker/wordpress/Dockerfile
grep -Fxq 'ARG WORDPRESS_BASE_IMAGE=wordpress:${VERSION_WORDPRESS}-php${VERSION_PHP}-fpm' .docker/wordpress/Dockerfile
grep -Fxq 'FROM ${WORDPRESS_BASE_IMAGE}' .docker/wordpress/Dockerfile
}

@test "CI defaults to Renovate-managed image and allows an override" {
run grep -Fc 'WORDPRESS_BASE_IMAGE=${{ inputs.wordpress_base_image || env.WORDPRESS_BASE_IMAGE }}' .github/workflows/docker-publish.yml
[ "$status" -eq 0 ]
[ "$output" -eq 2 ]

run grep -Ec 'WORDPRESS_BASE_IMAGE: wordpress:[0-9]+\.[0-9]+\.[0-9]+-php[0-9]+\.[0-9]+-fpm@sha256:[a-f0-9]{64}' .github/workflows/docker-publish.yml
[ "$status" -eq 0 ]
[ "$output" -eq 1 ]
}
Loading