diff --git a/Dockerfile b/Dockerfile index be61944..d8f9c37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..06ba105 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/config.json b/config.json index 835b08d..17bb4b1 100644 --- a/config.json +++ b/config.json @@ -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" } } ] \ No newline at end of file diff --git a/generate-config.sh b/generate-config.sh new file mode 100755 index 0000000..6528ddc --- /dev/null +++ b/generate-config.sh @@ -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}" \ No newline at end of file diff --git a/versions.yml b/versions.yml new file mode 100644 index 0000000..c3f5e8c --- /dev/null +++ b/versions.yml @@ -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 ] \ No newline at end of file