Skip to content

Commit f0b7532

Browse files
authored
Merge pull request #11 from kool-dev/php81
Adding PHP 8.1
2 parents 3ad5c4a + 69e0907 commit f0b7532

File tree

12 files changed

+515
-1
lines changed

12 files changed

+515
-1
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
version: [ 7.4, "8.0" ]
13+
version: [ '7.4', '8.0', '8.1' ]
1414
type: [ '', '-prod' ]
1515

1616
steps:

8.1-nginx-prod/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM wordpress:cli-php8.1 as wordpress-cli
2+
FROM wordpress:php8.1-fpm-alpine as wordpress
3+
FROM kooldev/php:8.1-nginx-prod
4+
5+
ENV NGINX_ROOT=/app
6+
7+
COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp
8+
COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress
9+
COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content
10+
COPY entrypoint /kool/wordpress-entrypoint
11+
12+
RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint
13+
14+
ENTRYPOINT [ "/kool/wordpress-entrypoint" ]
15+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.1-nginx-prod/entrypoint

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# Nginx server config
5+
dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf
6+
7+
# Run as current user
8+
CURRENT_USER=${ASUSER:-${UID:-0}}
9+
10+
if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
11+
usermod -u $CURRENT_USER kool
12+
fi
13+
14+
# user/group for Wordpress
15+
user=kool
16+
group=kool
17+
uid=$(id -u)
18+
19+
if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then
20+
# Original Wordpress Entrypoint - fresh install if none exists
21+
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
22+
# 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)
23+
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
24+
chown "$user:$group" .
25+
fi
26+
27+
echo >&2 "WordPress not found in $PWD - copying now..."
28+
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
29+
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
30+
fi
31+
sourceTarArgs=(
32+
--create
33+
--file -
34+
--directory /kool/wordpress
35+
--owner "$user" --group "$group"
36+
)
37+
targetTarArgs=(
38+
--extract
39+
--file -
40+
)
41+
if [ "$uid" != '0' ]; then
42+
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
43+
targetTarArgs+=( --no-overwrite-dir )
44+
fi
45+
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
46+
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
47+
for contentPath in \
48+
/kool/wordpress/.htaccess \
49+
/kool/wordpress/wp-content/*/*/ \
50+
; do
51+
contentPath="${contentPath%/}"
52+
[ -e "$contentPath" ] || continue
53+
contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc.
54+
if [ -e "$PWD/$contentPath" ]; then
55+
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
56+
sourceTarArgs+=( --exclude "./$contentPath" )
57+
fi
58+
done
59+
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
60+
chown -R "$user:$group" /app
61+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
62+
fi
63+
64+
wpEnvs=( "${!WORDPRESS_@}" )
65+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
66+
for wpConfigDocker in \
67+
wp-config-docker.php \
68+
/kool/wordpress/wp-config-docker.php \
69+
; do
70+
if [ -s "$wpConfigDocker" ]; then
71+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
72+
# 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)
73+
awk '
74+
/put your unique phrase here/ {
75+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
76+
cmd | getline str
77+
close(cmd)
78+
gsub("put your unique phrase here", str)
79+
}
80+
{ print }
81+
' "$wpConfigDocker" > wp-config.php
82+
if [ "$uid" = '0' ]; then
83+
# attempt to ensure that wp-config.php is owned by the run user
84+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
85+
chown "$user:$group" wp-config.php || true
86+
fi
87+
break
88+
fi
89+
done
90+
fi
91+
fi
92+
93+
exec /kool/entrypoint "$@"

8.1-nginx/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM wordpress:cli-php8.1 as wordpress-cli
2+
FROM wordpress:php8.1-fpm-alpine as wordpress
3+
FROM kooldev/php:8.1-nginx
4+
5+
ENV NGINX_ROOT=/app
6+
7+
COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp
8+
COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress
9+
COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content
10+
COPY entrypoint /kool/wordpress-entrypoint
11+
12+
RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint
13+
14+
ENTRYPOINT [ "/kool/wordpress-entrypoint" ]
15+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.1-nginx/entrypoint

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# Nginx server config
5+
dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf
6+
7+
# Run as current user
8+
CURRENT_USER=${ASUSER:-${UID:-0}}
9+
10+
if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
11+
usermod -u $CURRENT_USER kool
12+
fi
13+
14+
# user/group for Wordpress
15+
user=kool
16+
group=kool
17+
uid=$(id -u)
18+
19+
if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then
20+
# Original Wordpress Entrypoint - fresh install if none exists
21+
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
22+
# 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)
23+
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
24+
chown "$user:$group" .
25+
fi
26+
27+
echo >&2 "WordPress not found in $PWD - copying now..."
28+
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
29+
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
30+
fi
31+
sourceTarArgs=(
32+
--create
33+
--file -
34+
--directory /kool/wordpress
35+
--owner "$user" --group "$group"
36+
)
37+
targetTarArgs=(
38+
--extract
39+
--file -
40+
)
41+
if [ "$uid" != '0' ]; then
42+
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
43+
targetTarArgs+=( --no-overwrite-dir )
44+
fi
45+
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
46+
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
47+
for contentPath in \
48+
/kool/wordpress/.htaccess \
49+
/kool/wordpress/wp-content/*/*/ \
50+
; do
51+
contentPath="${contentPath%/}"
52+
[ -e "$contentPath" ] || continue
53+
contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc.
54+
if [ -e "$PWD/$contentPath" ]; then
55+
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
56+
sourceTarArgs+=( --exclude "./$contentPath" )
57+
fi
58+
done
59+
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
60+
chown -R "$user:$group" /app
61+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
62+
fi
63+
64+
wpEnvs=( "${!WORDPRESS_@}" )
65+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
66+
for wpConfigDocker in \
67+
wp-config-docker.php \
68+
/kool/wordpress/wp-config-docker.php \
69+
; do
70+
if [ -s "$wpConfigDocker" ]; then
71+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
72+
# 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)
73+
awk '
74+
/put your unique phrase here/ {
75+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
76+
cmd | getline str
77+
close(cmd)
78+
gsub("put your unique phrase here", str)
79+
}
80+
{ print }
81+
' "$wpConfigDocker" > wp-config.php
82+
if [ "$uid" = '0' ]; then
83+
# attempt to ensure that wp-config.php is owned by the run user
84+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
85+
chown "$user:$group" wp-config.php || true
86+
fi
87+
break
88+
fi
89+
done
90+
fi
91+
fi
92+
93+
exec /kool/entrypoint "$@"

8.1-prod/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM wordpress:cli-php8.1 as wordpress-cli
2+
FROM wordpress:php8.1-fpm-alpine as wordpress
3+
FROM kooldev/php:8.1-prod
4+
5+
6+
COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp
7+
COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress
8+
COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content
9+
COPY entrypoint /kool/wordpress-entrypoint
10+
11+
RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint
12+
13+
ENTRYPOINT [ "/kool/wordpress-entrypoint" ]
14+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.1-prod/entrypoint

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
5+
# Run as current user
6+
CURRENT_USER=${ASUSER:-${UID:-0}}
7+
8+
if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
9+
usermod -u $CURRENT_USER kool
10+
fi
11+
12+
# user/group for Wordpress
13+
user=kool
14+
group=kool
15+
uid=$(id -u)
16+
17+
if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then
18+
# Original Wordpress Entrypoint - fresh install if none exists
19+
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
20+
# 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)
21+
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
22+
chown "$user:$group" .
23+
fi
24+
25+
echo >&2 "WordPress not found in $PWD - copying now..."
26+
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
27+
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
28+
fi
29+
sourceTarArgs=(
30+
--create
31+
--file -
32+
--directory /kool/wordpress
33+
--owner "$user" --group "$group"
34+
)
35+
targetTarArgs=(
36+
--extract
37+
--file -
38+
)
39+
if [ "$uid" != '0' ]; then
40+
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
41+
targetTarArgs+=( --no-overwrite-dir )
42+
fi
43+
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
44+
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
45+
for contentPath in \
46+
/kool/wordpress/.htaccess \
47+
/kool/wordpress/wp-content/*/*/ \
48+
; do
49+
contentPath="${contentPath%/}"
50+
[ -e "$contentPath" ] || continue
51+
contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc.
52+
if [ -e "$PWD/$contentPath" ]; then
53+
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
54+
sourceTarArgs+=( --exclude "./$contentPath" )
55+
fi
56+
done
57+
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
58+
chown -R "$user:$group" /app
59+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
60+
fi
61+
62+
wpEnvs=( "${!WORDPRESS_@}" )
63+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
64+
for wpConfigDocker in \
65+
wp-config-docker.php \
66+
/kool/wordpress/wp-config-docker.php \
67+
; do
68+
if [ -s "$wpConfigDocker" ]; then
69+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
70+
# 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)
71+
awk '
72+
/put your unique phrase here/ {
73+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
74+
cmd | getline str
75+
close(cmd)
76+
gsub("put your unique phrase here", str)
77+
}
78+
{ print }
79+
' "$wpConfigDocker" > wp-config.php
80+
if [ "$uid" = '0' ]; then
81+
# attempt to ensure that wp-config.php is owned by the run user
82+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
83+
chown "$user:$group" wp-config.php || true
84+
fi
85+
break
86+
fi
87+
done
88+
fi
89+
fi
90+
91+
exec /kool/entrypoint "$@"

8.1/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM wordpress:cli-php8.1 as wordpress-cli
2+
FROM wordpress:php8.1-fpm-alpine as wordpress
3+
FROM kooldev/php:8.1
4+
5+
6+
COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp
7+
COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress
8+
COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content
9+
COPY entrypoint /kool/wordpress-entrypoint
10+
11+
RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint
12+
13+
ENTRYPOINT [ "/kool/wordpress-entrypoint" ]
14+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

0 commit comments

Comments
 (0)