Skip to content

Instantly share code, notes, and snippets.

@b4dnewz
Last active January 30, 2019 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b4dnewz/ca6a45cd286d2d95b0fa09de909659d0 to your computer and use it in GitHub Desktop.
Save b4dnewz/ca6a45cd286d2d95b0fa09de909659d0 to your computer and use it in GitHub Desktop.
An extended WordPress image designed for easy and fast development.
version: '3'
services:
db:
image: mysql:5.7
restart: always
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wp:
image: codekraft/wordpress-dev
restart: always
volumes:
- ./themes:/var/www/html/wp-content/themes
- ./plugins:/var/www/html/wp-content/plugins
depends_on:
- db
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
# WordPress Development
# An custom container extended with development tools
#
# Usage: docker build .
# docker build --build-arg VERSION=4.9 .
# docker build --build-arg USERID=$(id -u) .
ARG VERSION=latest
FROM wordpress:$VERSION
# Update packages list and install less (required from wp-cli)
RUN apt update && apt install less
# Change server user id to match host
ARG USERID=1000
RUN usermod -u $USERID www-data
# Download and install wp-cli
RUN curl -o /bin/wpcli https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /bin/wpcli
# Add an alias script to run wpcli as www-data user
RUN echo '#! /bin/sh' >> /bin/wp
RUN echo 'runuser -u www-data -- wpcli "$@"' >> /bin/wp
RUN chmod +x /bin/wp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment