Skip to content

Commit

Permalink
Merge pull request #12 from kool-dev/8.2
Browse files Browse the repository at this point in the history
Add 8.2
  • Loading branch information
dbpolito authored Sep 12, 2023
2 parents f0b7532 + 1fc2d37 commit df89e46
Show file tree
Hide file tree
Showing 24 changed files with 1,054 additions and 532 deletions.
54 changes: 42 additions & 12 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI/CD

on: [push, workflow_dispatch]
on:
push:
workflow_dispatch:

env:
DOCKER_BUILDKIT: 1
Expand All @@ -10,22 +12,32 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ '7.4', '8.0', '8.1' ]
version: [ '7.4', '8.0', '8.1', '8.2' ]
type: [ '', '-prod' ]

steps:
- name: Checkout code
uses: actions/checkout@master
uses: actions/checkout@v3

- name: Build image
run: |
docker build \
--tag kooldev/wordpress:${{ matrix.version }}${{ matrix.type }} \
${{ matrix.version }}${{ matrix.type }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: ${{ matrix.version }}${{ matrix.type }}
load: true
tags: kooldev/wordpress:${{ matrix.version }}${{ matrix.type }}

docker build \
--tag kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} \
${{ matrix.version }}-nginx${{ matrix.type }}
- name: Build and export to Docker (nginx)
uses: docker/build-push-action@v3
with:
context: ${{ matrix.version }}-nginx${{ matrix.type }}
load: true
tags: kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }}

- name: Test docker images PHP executable
run: |
Expand All @@ -44,7 +56,7 @@ jobs:
docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} php /kool/wordpress/index.php
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress'
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -55,3 +67,21 @@ jobs:
run: |
docker push kooldev/wordpress:${{ matrix.version }}${{ matrix.type }}
docker push kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }}
- name: Build and push
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress'
with:
context: ${{ matrix.version }}${{ matrix.type }}
platforms: linux/amd64,linux/arm64
push: true
tags: kooldev/wordpress:${{ matrix.version }}${{ matrix.type }}

- name: Build and push (nginx)
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress'
with:
context: ${{ matrix.version }}-nginx${{ matrix.type }}
platforms: linux/amd64,linux/arm64
push: true
tags: kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }}
79 changes: 39 additions & 40 deletions 7.4-nginx-prod/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,76 @@ user=kool
group=kool
uid=$(id -u)

if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then
if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then
# Original Wordpress Entrypoint - fresh install if none exists
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory)
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
--create
--file -
--directory /kool/wordpress
--owner "$user" --group "$group"
--create
--file -
--directory /kool/wordpress
--owner "$user" --group "$group"
)
targetTarArgs=(
--extract
--file -
--extract
--file -
)
if [ "$uid" != '0' ]; then
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
fi
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
for contentPath in \
/kool/wordpress/.htaccess \
/kool/wordpress/wp-content/*/*/ \
/kool/wordpress/.htaccess \
/kool/wordpress/wp-content/*/*/ \
; do
contentPath="${contentPath%/}"
[ -e "$contentPath" ] || continue
contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc.
if [ -e "$PWD/$contentPath" ]; then
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
fi
done
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
chown -R "$user:$group" /app
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi

wpEnvs=( "${!WORDPRESS_@}" )
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
for wpConfigDocker in \
wp-config-docker.php \
/kool/wordpress/wp-config-docker.php \
; do
if [ -s "$wpConfigDocker" ]; then
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
# using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables)
awk '
/put your unique phrase here/ {
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
cmd | getline str
close(cmd)
gsub("put your unique phrase here", str)
}
{ print }
' "$wpConfigDocker" > wp-config.php
if [ "$uid" = '0' ]; then
# attempt to ensure that wp-config.php is owned by the run user
# could be on a filesystem that doesn't allow chown (like some NFS setups)
chown "$user:$group" wp-config.php || true
fi
break
fi
done
for wpConfigDocker in \
wp-config-docker.php \
/kool/wordpress/wp-config-docker.php \
; do
if [ -s "$wpConfigDocker" ]; then
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
# using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables)
awk '
/put your unique phrase here/ {
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
cmd | getline str
close(cmd)
gsub("put your unique phrase here", str)
}
{ print }
' "$wpConfigDocker" > wp-config.php
if [ "$uid" = '0' ]; then
# attempt to ensure that wp-config.php is owned by the run user
# could be on a filesystem that doesn't allow chown (like some NFS setups)
chown "$user:$group" wp-config.php || true
fi
break
fi
done
fi
fi

Expand Down
79 changes: 39 additions & 40 deletions 7.4-nginx/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,76 @@ user=kool
group=kool
uid=$(id -u)

if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then
if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then
# Original Wordpress Entrypoint - fresh install if none exists
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory)
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
--create
--file -
--directory /kool/wordpress
--owner "$user" --group "$group"
--create
--file -
--directory /kool/wordpress
--owner "$user" --group "$group"
)
targetTarArgs=(
--extract
--file -
--extract
--file -
)
if [ "$uid" != '0' ]; then
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
fi
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
for contentPath in \
/kool/wordpress/.htaccess \
/kool/wordpress/wp-content/*/*/ \
/kool/wordpress/.htaccess \
/kool/wordpress/wp-content/*/*/ \
; do
contentPath="${contentPath%/}"
[ -e "$contentPath" ] || continue
contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc.
if [ -e "$PWD/$contentPath" ]; then
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
fi
done
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
chown -R "$user:$group" /app
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi

wpEnvs=( "${!WORDPRESS_@}" )
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
for wpConfigDocker in \
wp-config-docker.php \
/kool/wordpress/wp-config-docker.php \
; do
if [ -s "$wpConfigDocker" ]; then
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
# using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables)
awk '
/put your unique phrase here/ {
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
cmd | getline str
close(cmd)
gsub("put your unique phrase here", str)
}
{ print }
' "$wpConfigDocker" > wp-config.php
if [ "$uid" = '0' ]; then
# attempt to ensure that wp-config.php is owned by the run user
# could be on a filesystem that doesn't allow chown (like some NFS setups)
chown "$user:$group" wp-config.php || true
fi
break
fi
done
for wpConfigDocker in \
wp-config-docker.php \
/kool/wordpress/wp-config-docker.php \
; do
if [ -s "$wpConfigDocker" ]; then
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
# using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables)
awk '
/put your unique phrase here/ {
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
cmd | getline str
close(cmd)
gsub("put your unique phrase here", str)
}
{ print }
' "$wpConfigDocker" > wp-config.php
if [ "$uid" = '0' ]; then
# attempt to ensure that wp-config.php is owned by the run user
# could be on a filesystem that doesn't allow chown (like some NFS setups)
chown "$user:$group" wp-config.php || true
fi
break
fi
done
fi
fi

Expand Down
Loading

0 comments on commit df89e46

Please sign in to comment.