Skip to content

Commit af94733

Browse files
authored
Merge pull request #13 from kool-dev/8.3
Adding 8.3
2 parents df89e46 + 10acdfa commit af94733

File tree

12 files changed

+516
-1
lines changed

12 files changed

+516
-1
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
version: [ '7.4', '8.0', '8.1', '8.2' ]
15+
version: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
1616
type: [ '', '-prod' ]
1717

1818
steps:

8.3-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.3 as wordpress-cli
2+
FROM wordpress:php8.3-fpm-alpine as wordpress
3+
FROM kooldev/php:8.3-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.3-nginx-prod/entrypoint

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
61+
fi
62+
63+
wpEnvs=( "${!WORDPRESS_@}" )
64+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
65+
for wpConfigDocker in \
66+
wp-config-docker.php \
67+
/kool/wordpress/wp-config-docker.php \
68+
; do
69+
if [ -s "$wpConfigDocker" ]; then
70+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
71+
# 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)
72+
awk '
73+
/put your unique phrase here/ {
74+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
75+
cmd | getline str
76+
close(cmd)
77+
gsub("put your unique phrase here", str)
78+
}
79+
{ print }
80+
' "$wpConfigDocker" > wp-config.php
81+
if [ "$uid" = '0' ]; then
82+
# attempt to ensure that wp-config.php is owned by the run user
83+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
84+
chown "$user:$group" wp-config.php || true
85+
fi
86+
break
87+
fi
88+
done
89+
fi
90+
fi
91+
92+
exec /kool/entrypoint "$@"

8.3-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.3 as wordpress-cli
2+
FROM wordpress:php8.3-fpm-alpine as wordpress
3+
FROM kooldev/php:8.3-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.3-nginx/entrypoint

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
61+
fi
62+
63+
wpEnvs=( "${!WORDPRESS_@}" )
64+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
65+
for wpConfigDocker in \
66+
wp-config-docker.php \
67+
/kool/wordpress/wp-config-docker.php \
68+
; do
69+
if [ -s "$wpConfigDocker" ]; then
70+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
71+
# 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)
72+
awk '
73+
/put your unique phrase here/ {
74+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
75+
cmd | getline str
76+
close(cmd)
77+
gsub("put your unique phrase here", str)
78+
}
79+
{ print }
80+
' "$wpConfigDocker" > wp-config.php
81+
if [ "$uid" = '0' ]; then
82+
# attempt to ensure that wp-config.php is owned by the run user
83+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
84+
chown "$user:$group" wp-config.php || true
85+
fi
86+
break
87+
fi
88+
done
89+
fi
90+
fi
91+
92+
exec /kool/entrypoint "$@"

8.3-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.3 as wordpress-cli
2+
FROM wordpress:php8.3-fpm-alpine as wordpress
3+
FROM kooldev/php:8.3-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.3-prod/entrypoint

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
59+
fi
60+
61+
wpEnvs=( "${!WORDPRESS_@}" )
62+
if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
63+
for wpConfigDocker in \
64+
wp-config-docker.php \
65+
/kool/wordpress/wp-config-docker.php \
66+
; do
67+
if [ -s "$wpConfigDocker" ]; then
68+
echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
69+
# 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)
70+
awk '
71+
/put your unique phrase here/ {
72+
cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1"
73+
cmd | getline str
74+
close(cmd)
75+
gsub("put your unique phrase here", str)
76+
}
77+
{ print }
78+
' "$wpConfigDocker" > wp-config.php
79+
if [ "$uid" = '0' ]; then
80+
# attempt to ensure that wp-config.php is owned by the run user
81+
# could be on a filesystem that doesn't allow chown (like some NFS setups)
82+
chown "$user:$group" wp-config.php || true
83+
fi
84+
break
85+
fi
86+
done
87+
fi
88+
fi
89+
90+
exec /kool/entrypoint "$@"

8.3/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM wordpress:cli-php8.3 as wordpress-cli
2+
FROM wordpress:php8.3-fpm-alpine as wordpress
3+
FROM kooldev/php:8.3
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)