Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
markgoodyear committed Jan 3, 2023
2 parents ef70e36 + 95b9940 commit 9611bc6
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 61 deletions.
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ ARG WORDPRESS_IMAGE

FROM wordpress:${WORDPRESS_IMAGE}

# Installs mhsendmail for Mailhog.
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 && \
chmod +x /usr/local/bin/mhsendmail
# Install Mailpit.
RUN ["/bin/bash", "-c", "bash < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)"]

# Configures sendmail_path and sends to mailhog container.
RUN echo 'sendmail_path="/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025"' > /usr/local/etc/php/conf.d/mailhog.ini
# Configure sendmail to use Mailpit.
RUN echo 'sendmail_path="/usr/local/bin/mailpit sendmail --smtp-addr=mail:1025"' > /usr/local/etc/php/conf.d/mail.ini

# Easy installation of PHP extensions in official PHP Docker images: https://github.com/mlocati/docker-php-extension-installer/.
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

# Install PHP extensions.
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions memcache memcached xdebug
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Jetty WordPress Image
> This image is based off the official Docker image maintained by the Docker community: https://hub.docker.com/_/wordpress
## Adding New Image Versions
The `versions.yml` contains the config for the image versions supported. When adding new versions, please check the tags supported by the WordPress image: https://hub.docker.com/_/wordpress/tags.

Example `versions.yml`:
```yml
6.0: [8.1, 8,0]
```
This will generate the `config.json` for the CircleCI `bigbite/docker-image-extend` orb, containing WordPress 6.0, with PHP versions 8.1 and 8.0:

Example generated `conifg.json`:
```json
[
{ "tag": "6.0-php8.1", "args": { "WORDPRESS_IMAGE": "6.0-php8.1" } },
{ "tag": "6.0-php8.0", "args": { "WORDPRESS_IMAGE": "6.0-php8.0" } },
]
```

To generate the `config.json` file, run:

```
./generate-config.sh versions.yml > config.json
```
65 changes: 9 additions & 56 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,11 @@
[
{
"tag": "6.0-php8.1",
"args": {
"WORDPRESS_IMAGE": "6.0-php8.1"
}
},
{
"tag": "6.0-php8.0",
"args": {
"WORDPRESS_IMAGE": "6.0-php8.0"
}
},
{
"tag": "6.0-php7.4",
"args": {
"WORDPRESS_IMAGE": "6.0-php7.4"
}
},

{
"tag": "5.9-php8.1",
"args": {
"WORDPRESS_IMAGE": "5.9-php8.1"
}
},
{
"tag": "5.9-php8.0",
"args": {
"WORDPRESS_IMAGE": "5.9-php8.0"
}
},
{
"tag": "5.9-php7.4",
"args": {
"WORDPRESS_IMAGE": "5.9-php7.4"
}
},

{
"tag": "5.8-php8.1",
"args": {
"WORDPRESS_IMAGE": "5.8-php8.1"
}
},
{
"tag": "5.8-php8.0",
"args": {
"WORDPRESS_IMAGE": "5.8-php8.0"
}
},
{
"tag": "5.8-php7.4",
"args": {
"WORDPRESS_IMAGE": "5.8-php7.4"
}
}
{ "tag": "6.1-php8.1", "args": { "WORDPRESS_IMAGE": "6.1-php8.1" } },
{ "tag": "6.1-php8.0", "args": { "WORDPRESS_IMAGE": "6.1-php8.0" } },
{ "tag": "6.1-php7.4", "args": { "WORDPRESS_IMAGE": "6.1-php7.4" } },
{ "tag": "6.0-php8.1", "args": { "WORDPRESS_IMAGE": "6.0-php8.1" } },
{ "tag": "6.0-php8.0", "args": { "WORDPRESS_IMAGE": "6.0-php8.0" } },
{ "tag": "6.0-php7.4", "args": { "WORDPRESS_IMAGE": "6.0-php7.4" } },
{ "tag": "5.9-php8.1", "args": { "WORDPRESS_IMAGE": "5.9-php8.1" } },
{ "tag": "5.9-php8.0", "args": { "WORDPRESS_IMAGE": "5.9-php8.0" } },
{ "tag": "5.9-php7.4", "args": { "WORDPRESS_IMAGE": "5.9-php7.4" } }
]
83 changes: 83 additions & 0 deletions generate-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

# if no file supplied, exit
if [[ ! -f "$1" ]]; then
>&2 echo "File does not exist, or was not specified.";
exit 1;
fi

# check whether verbose output is enabled
declare -a positional_args;
while [[ $# -gt 0 ]]; do
case $1 in
--verbose|-v)
verbose=1;
shift;
;;
--*|-*)
>&2 echo "Unknown option $1";
exit 1;
;;
*)
positional_args+=("$1");
shift;
;;
esac
done
set -- "${positional_args[@]}";

# output verbose messages
function verbose() {
if [ $verbose ]; then
>&2 echo "$1";
fi
}

# create an array to store our list of image strings
declare -a images;

# read file one line at a time.
# each line contains the following:
# wp.version: [php.version1,php.version2 ...]
while IFS= read -r line; do
verbose 'Reading line:';
verbose "- $line";

# line is keyed by wp version, so everything before the first semicolon is the wp version.
wpVersion=$(echo "$line" | awk -F':' '{print $1}');
verbose "- - WP Version: $wpVersion";

# value for each line is an array of php versions, so everything after the semicolon is the array
# use sed to strip anything that isn't a number, comma, or period, which leaves a csv of php versions
phpVersions=$(echo "$line" | awk -F':' '{print $2}' | sed 's/[^0-9.,]//g');
verbose "- - PHP Versions: $phpVersions";

# split the php versions into an array by "exploding" on the comma
IFS=',' read -r -a phpVersions <<< "$phpVersions"

# for each version in the array
for php in "${phpVersions[@]}"; do
verbose "- - - Using PHP Version: $php";

# build the image name
image=$(printf '%s-php%s' "$wpVersion" "$php");
verbose "- - - Image Name: $image";

# build the json entry for the image name, and add to an array of images
images+=("$(printf '{ "tag": "%s", "args": { "WORDPRESS_IMAGE": "%s" } }' "$image" "$image")");
verbose "- - Generated JSON Entry: $(printf '{ "tag": "%s", "args": { "WORDPRESS_IMAGE": "%s" } }' "$image" "$image")";
done;
done < "$1";

# start building the json!
verbose 'Building JSON';
json='';

# for each found image
for ((i = 0; i < "${#images[@]}"; i++)); do
# add to the json string
json=$(printf "%s,\n %s" "$json" "${images[$i]}");
done

# wrap the string in an array to make it valid (lose the leading delims.)
printf "[\n%s\n]" "${json:2}"
4 changes: 4 additions & 0 deletions versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
6.1: [ 8.1, 8.0, 7.4 ]
6.0: [ 8.1, 8.0, 7.4 ]
5.9: [ 8.1, 8.0, 7.4 ]
5.8: [ 8.1, 8.0, 7.4 ]

0 comments on commit 9611bc6

Please sign in to comment.