Skip to content

Commit

Permalink
Added Docker for local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin J. DeLong committed Jul 17, 2018
1 parent ee13546 commit f4c1b36
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 39 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM php:7.2-alpine

MAINTAINER @bozdoz

# install the PHP extensions we need for WP-CLI
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
libjpeg-turbo-dev \
libpng-dev \
; \
\
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
docker-php-ext-install gd mysqli opcache zip; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .wordpress-phpexts-rundeps $runDeps; \
apk del .build-deps

RUN set -ex; \
mkdir -p /var/www/html; \
chown -R www-data:www-data /var/www/html

WORKDIR /var/www/html
VOLUME /var/www/html

RUN curl -L https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /usr/bin/wp && \
chmod +x /usr/bin/wp

ENV WORDPRESS_PORT 1234

COPY docker-install.sh /usr/local/bin/

RUN chmod 755 /usr/local/bin/docker-install.sh

CMD [ "docker-install.sh" ]
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: '3.3'

services:
db:
image: mariadb
volumes:
- wp_db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
image: wordpress:latest
depends_on:
- db
volumes:
- wordpress:/var/www/html
- .:/var/www/html/wp-content/plugins/leaflet-map
ports:
- 1234:80
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress

cli:
build: .
depends_on:
- wordpress
volumes:
- wordpress:/var/www/html
- .:/var/www/html/wp-content/plugins/leaflet-map
environment:
WORDPRESS_PORT: 1234

volumes:
wp_db:
wordpress:
24 changes: 24 additions & 0 deletions docker-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -euo pipefail

if [[ -f wp-config.php && -f .cli-initialized ]]; then
exit 0
fi

if [ ! -f wp-config.php ]; then
echo "WordPress not found in $PWD!"
( set -x; ls -A; sleep 15 )
fi

if [ ! -f .cli-initialized ]; then
echo "Initializing WordPress install!"
wp --allow-root core install --url="localhost:$WORDPRESS_PORT" --title="Test Leaflet Map" --admin_user=admin --admin_password=password [email protected] --skip-email

wp --allow-root config set WP_DEBUG true --raw

wp --allow-root plugin activate leaflet-map

wp --allow-root post create --post_type=post --post_title='Test Map' --post_content='[leaflet-map] [leaflet-marker]' --post_status='publish'

touch .cli-initialized
fi
74 changes: 37 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "leaflet-map",
"version": "2.11.0",
"version": "2.11.1",
"description": "Leaflet Map WordPress Plugin",
"main": "index.js",
"scripts": {
"minify": "for file in scripts/*.js; do minify $file > ./scripts/$(basename $file .js).min.js; done",
"start": "docker-compose up",
"minify": "npm run clean && for file in scripts/*.js; do minify $file > ./scripts/$(basename $file .js).min.js; done",
"clean": "rm scripts/*.min.js",
"translate": "cd ./languages && sudo php ../../wp-trunk/tools/i18n/makepot.php wp-plugin ../",
"svn": "cd ./svn/trunk && git pull && cd .. && svn cp trunk/ tags/2.10.0",
Expand Down

0 comments on commit f4c1b36

Please sign in to comment.