commit bf89bdbe8cb65b58c51163301bbdef9ed945ed2c Author: meskio Date: Sun Dec 18 00:26:19 2022 +0100 First steps diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2251053 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM registry.sindominio.net/nginx-php + +RUN apt-get update && \ + apt-get -qy install --no-install-recommends \ + gnupg ca-certificates less \ + php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-redis && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# install wp-cli +ADD https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar /usr/local/bin/wp +RUN chmod +rx /usr/local/bin/wp + +# verify wp-cli signature +COPY wp-key.asc /key.asc +ADD https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar.asc /wp.asc +RUN gpg --import /key.asc && \ + gpg --verify /wp.asc /usr/local/bin/wp + +RUN mkdir /app +WORKDIR /app + +# install wordpress +RUN wp --allow-root core download +ADD wp-config.php /app/ +# TODO: install themes and plugins + +VOLUME /app/wp-content/uploads + +ADD setup /etc/setup diff --git a/README.md b/README.md new file mode 100644 index 0000000..65d1aa8 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# container image of WordPress + +``` +$ mkdir uploads db +$ cp env.sample .env +$ vim .env +``` + +Customize parameters + +## Custom themes or pluggins + +To include custom themes or pluggins mount them directly into /app/wp-content/: +``` + volumes: + - ./uploads:/app/wp-content/uploads + - ./mytheme:/app/wp-content/themes/mytheme +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..35c62a1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +version: '2.4' + +services: + db: + # TODO: fix our mariadb container + #image: registry.sindominio.net/mariadb + image: mysql + user: "$USER_GROUP" + restart: always + volumes: + - ./db:/var/lib/mysql + environment: + - MYSQL_RANDOM_ROOT_PASSWORD=1 + - MYSQL_DATABASE + - MYSQL_USER + - MYSQL_PASSWORD + + wordpress: + image: registry.sindominio.net/wordpress + user: "$USER_GROUP" + restart: always + depends_on: + - db + volumes: + - ./uploads:/app/wp-content/uploads + ports: + - 8080:8080 + environment: + - MYSQL_HOST=db + - MYSQL_DATABASE + - MYSQL_USER + - MYSQL_PASSWORD + - WP_USER + - WP_PASS + - WP_EMAIL + - WP_TITLE + - WP_URL + diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..46f677a --- /dev/null +++ b/env.sample @@ -0,0 +1,11 @@ +MYSQL_DATABASE=wordpress +MYSQL_USER=wordpress +MYSQL_PASSWORD=wordpress + +USER_GROUP=1000:1000 + +WP_USER=admin +WP_PASS=admin +WP_EMAIL=real@mail.org +WP_TITLE=Wordpress Title +WP_URL=http://docker:8080 diff --git a/setup b/setup new file mode 100755 index 0000000..0222836 --- /dev/null +++ b/setup @@ -0,0 +1,15 @@ +#!/bin/sh + +export WORDPRESS_ROOT=/app +WP_CLI="/usr/local/bin/wp --allow-root --path=$WORDPRESS_ROOT" + +# TODO: wait for the DB to be ready +sleep 10 + +if ! $WP_CLI core is-installed; then + echo "Install Wordpress" + $WP_CLI core install --url="$WP_URL" --title="$WP_TITLE" --admin_user="$WP_USER" --admin_password="$WP_PASS" --admin_email="$WP_EMAIL" +else + echo "Update DB" + $WP_CLI core update-db +fi diff --git a/version b/version new file mode 100755 index 0000000..31ee103 --- /dev/null +++ b/version @@ -0,0 +1,8 @@ +#!/bin/sh + +# https://codex.wordpress.org/WordPress.org_API +WP=`curl -s https://api.wordpress.org/core/version-check/1.7/ |jq -r '.offers[0].version'` + +WP_CLI=`curl -s https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar |sha256sum |awk '{ print $1 }'` + +echo "$WP:$WP_CLI" diff --git a/wp-config.php b/wp-config.php new file mode 100644 index 0000000..e46158d --- /dev/null +++ b/wp-config.php @@ -0,0 +1,134 @@ +