Skip to content

Commit a161818

Browse files
committed
feat: add support for C3 Cloudfront Clear Cache envs
1 parent 87d7ac2 commit a161818

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ FROM wordpress:cli-${CLI_VERSION}-php${PHP_VERSION} AS wp-cli-source
1111

1212
FROM wordpress:${WORDPRESS_VERSION}-php${PHP_VERSION}-${FLAVOR} AS base
1313

14+
FROM alpine AS config-file
15+
RUN apk add --no-cache sd ripgrep
16+
COPY wp-config.ext.php /
17+
COPY --from=base /usr/src/wordpress/wp-config-docker.php /
18+
RUN <<EOT
19+
set -eu
20+
ext="$(cat /wp-config.ext.php)"
21+
match="/* That's all, stop editing! Happy publishing. */"
22+
nl=$'\n'
23+
rg --fixed-strings --quiet "$match" /wp-config-docker.php
24+
sd --fixed-strings --max-replacements=1 "$match" "${ext}${nl}${nl}${match}" /wp-config-docker.php
25+
EOT
26+
27+
FROM base
28+
1429
COPY --from=wp-cli-source /usr/local/bin/wp /usr/local/bin/wp
1530
ENV WP_CLI_ALLOW_ROOT=1
1631
ENV PAGER=cat
@@ -48,4 +63,5 @@ RUN --mount=type=bind,from=ext-installer,src=/usr/bin/install-php-extensions,dst
4863
install-php-extensions $PHP_EXTENSIONS
4964
EOT
5065

66+
COPY --from=config-file /wp-config-docker.php /usr/src/wordpress/wp-config-docker.php
5167
COPY --chown=www-data:www-data wp-content /usr/src/wordpress/wp-content

wp-config.ext.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* C3 Cloudfront Clear Cache envs */
2+
define('AWS_ACCESS_KEY_ID', getenv_docker('AWS_ACCESS_KEY_ID', null));
3+
define('AWS_SECRET_ACCESS_KEY', getenv_docker('AWS_SECRET_ACCESS_KEY', null));
4+
define('C3_DISTRIBUTION_ID', getenv_docker('C3_DISTRIBUTION_ID', null));
5+
define('C3_DISTRIBUTION_TENANT_ID', getenv_docker('C3_DISTRIBUTION_TENANT_ID', null));

0 commit comments

Comments
 (0)