Skip to content

Commit

Permalink
Merge pull request #1 from maiorano84/feature/wordmove
Browse files Browse the repository at this point in the history
Feature/wordmove
  • Loading branch information
maiorano84 authored Dec 18, 2020
2 parents 4a42490 + b8af866 commit 233eea0
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ MYSQL_ROOT_PASSWORD=secret
MYSQL_USER=bedrock
MYSQL_PASSWORD=secret
MYSQL_DATABASE=bedrock

# Wordmove
SSH_PATH=~/.ssh
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
docker/nginx/logs
!docker/nginx/logs/.gitkeep
logs/*
!logs/**/.gitkeep
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bedrock Project

A project scaffold for getting up and running quickly with
A local project scaffold for getting up and running quickly with
a [Roots/Bedrock](https://roots.io/bedrock/) project over Docker Compose

# Requirements
Expand Down Expand Up @@ -49,16 +49,28 @@ automatically proxy requests to the running NGINX configuration.

```
docker network create -d bridge traefik-network
docker build -t traefik-web ./docker/traefik
```

## Container

```
docker build -t traefik-web ./docker/traefik
docker run -itd --restart unless-stopped \
-p 80:80 -p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
--name=traefik --network=traefik-network traefik-web
```

Once running, you may also access the Traefik Dashboard by navigating to http://localhost:8080

# CLI Tools

Some command line tools are available as Compose services to make life a little easier:

* `composer` - [Composer](https://getcomposer.org/)
* `wp` - [WP CLI](https://wp-cli.org/)
* `wordmove` - [Wordmove](https://github.com/welaika/wordmove)

To run a CLI command as a service, simply run the following:

`docker-compose -f docker-compose.cli.yml run --rm <service>...`
29 changes: 29 additions & 0 deletions docker-compose.cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'

services:
composer:
image: composer:latest
volumes:
- ./code:/app
networks:
- default
- traefik
wp:
extends:
file: ./docker/services-common.yml
service: wp
networks:
- default
- traefik
wordmove:
extends:
file: ./docker/services-common.yml
service: wordmove
networks:
- default
- traefik

networks:
traefik:
external:
name: traefik-network
8 changes: 0 additions & 8 deletions docker-compose.traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ services:
extends:
file: ./docker/services-common.yml
service: nginx
volumes:
- ./code:/var/www/html
- ./docker/nginx/logs:/var/log/nginx
- ./docker/nginx/servers:/docker-entrypoint.d
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`${NGINX_SERVER_NAME}`)"
Expand All @@ -19,14 +15,10 @@ services:
extends:
file: ./docker/services-common.yml
service: mysql
volumes:
- mysql:/var/lib/mysql
php:
extends:
file: ./docker/services-common.yml
service: php
volumes:
- ./code:/var/www/html
depends_on:
- mysql

Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ services:
extends:
file: ./docker/services-common.yml
service: nginx
volumes:
- ./code:/var/www/html
- ./docker/nginx/logs:/var/log/nginx
- ./docker/nginx/servers:/docker-entrypoint.d
ports:
- "${NGINX_PORT:-80}:80"
depends_on:
Expand All @@ -17,14 +13,10 @@ services:
extends:
file: ./docker/services-common.yml
service: mysql
volumes:
- mysql:/var/lib/mysql
php:
extends:
file: ./docker/services-common.yml
service: php
volumes:
- ./code:/var/www/html
depends_on:
- mysql

Expand Down
35 changes: 35 additions & 0 deletions docker/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See: https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

server {
listen 80;
server_name {{NGINX_SERVER_NAME}};
root {{NGINX_ROOT}};
index index.php;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
26 changes: 0 additions & 26 deletions docker/nginx/servers/default.conf

This file was deleted.

8 changes: 8 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG PHP_VERSION=7.4

FROM wordpress:php${PHP_VERSION:-7.4}-fpm-alpine
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["php-fpm"]
6 changes: 6 additions & 0 deletions docker/php/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Fixes an uploads permissions issue on Windows
chown www-data:www-data -R /var/www/html

exec "$@"
35 changes: 34 additions & 1 deletion docker/services-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ x-db: &db-env
DB_NAME: ${MYSQL_DATABASE}
DB_USER: ${MYSQL_USER}
DB_PASSWORD: ${MYSQL_PASSWORD}
DB_PREFIX: ${MYSQL_PREFIX:-wp_}
DB_HOST: mysql
x-wp: &wp-env
WP_ENV: development
WP_HOME: http://${NGINX_SERVER_NAME}
WP_SITEURL: http://${NGINX_SERVER_NAME}/wp
WP_DEBUG_LOG: ${WP_DEBUG_LOG:-/var/log/bedrock}

services:
nginx:
Expand All @@ -18,6 +20,10 @@ services:
environment:
NGINX_SERVER_NAME: ${NGINX_SERVER_NAME}
NGINX_ROOT: ${NGINX_ROOT}
volumes:
- ../code:/var/www/html
- ../logs/nginx:/var/log/nginx
- ./nginx:/docker-entrypoint.d
mysql:
image: mariadb:10.1
ports:
Expand All @@ -27,10 +33,37 @@ services:
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
volumes:
- mysql:/var/lib/mysql
php:
image: maiorano84/php:${PHP_VERSION:-7.4}
build:
context: ./php
args:
PHP_VERSION: ${PHP_VERSION:-7.4}
ports:
- "9000"
environment:
<<: *db-env
<<: *wp-env
volumes:
- ../code:/var/www/html
- ../logs/bedrock:/var/log/bedrock
wordmove:
build:
context: ./wordmove
args:
PHP_VERSION: ${PHP_VERSION:-7.4}
environment:
<<: *db-env
<<: *wp-env
volumes:
- ../code:/var/www/html
- ${SSH_PATH}:/wordmove/.ssh
wp:
image: wordpress:cli-php${PHP_VERSION:-7.4}
environment:
<<: *db-env
<<: *wp-env
volumes:
- ../code:/var/www/html
entrypoint: ["wp"]
16 changes: 16 additions & 0 deletions docker/wordmove/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG PHP_VERSION=7.4

FROM php:${PHP_VERSION}-cli-alpine
ENV PAGER=more

COPY docker-entrypoint.sh /docker-entrypoint.sh

RUN apk add --update ruby ruby-etc ruby-bigdecimal ruby-json ruby-io-console curl mysql-client gzip rsync openssh && \
curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /usr/local/bin/wp && \
chmod +x /usr/local/bin/wp && \
gem install wordmove && \
chmod +x /docker-entrypoint.sh

WORKDIR /var/www/html

ENTRYPOINT ["/docker-entrypoint.sh"]
15 changes: 15 additions & 0 deletions docker/wordmove/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

eval `ssh-agent -s`

if [ ! -d "~/.ssh" ]; then
mkdir -p ~/.ssh
fi

cp -r /wordmove/.ssh/* ~/.ssh
find ~/.ssh -type f -not -name "*.pub" -not -name "known_hosts" -not -name "authorized_keys" -not -name "config" -follow -print | while read -r f; do
chmod 600 $f
ssh-add $f
done

wordmove "$@"
Empty file added logs/bedrock/.gitkeep
Empty file.
Empty file added logs/nginx/.gitkeep
Empty file.

0 comments on commit 233eea0

Please sign in to comment.