Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriipavlov committed Jan 14, 2022
2 parents 4705abf + 4d0ac28 commit 5019858
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 192 deletions.
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ upd:
$(ENV_INIT) $(t)
docker-compose up --build $(s)

# Root .env file concatenation and docker-compose up with nginx-proxy options
.PHONY: upp
upp:
$(ENV_INIT) $(t)
docker-compose -f docker-compose.yml -f docker-compose.proxy.yml up -d --build $(s)


######## Special modes ########
# Root .env file concatenation and docker-compose up. Stage mode
.PHONY: up-stage
Expand All @@ -45,7 +38,7 @@ up-stage:
.PHONY: up-prod
up-prod:
$(ENV_INIT) prod
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build $(s)
docker-compose up -d --build $(s)
######## Special modes ########


Expand Down
66 changes: 6 additions & 60 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@
</a>

<a href="https://hub.docker.com/_/wordpress">
<img alt="WordPress" src="https://img.shields.io/badge/WordPress-5.8-lightgrey">
<img alt="WordPress" src="https://img.shields.io/badge/WordPress-5.8.3-lightgrey">
</a>

<a href="https://hub.docker.com/_/nginx">
<img alt="Nginx" src="https://img.shields.io/badge/Nginx-1.20-00a652">
</a>

<a href="https://hub.docker.com/_/redis">
<img alt="Redis" src="https://img.shields.io/badge/Redis-6.2-d82c20">
<img alt="Nginx" src="https://img.shields.io/badge/Nginx-1.21-00a652">
</a>

<a href="https://hub.docker.com/_/phpmyadmin">
Expand All @@ -54,9 +50,8 @@
## Requirements

1. [Docker Engine](https://docs.docker.com/engine/install/) v20.10+
and [Docker Compose](https://docs.docker.com/compose/install/) v1.29+
2. To run few instances on port 80 need [Nginx-proxy](https://hub.docker.com/r/jwilder/nginx-proxy) (optional), or you can
use [Traefik](https://traefik.io/) (optional)
2. [Docker Compose](https://docs.docker.com/compose/install/) v1.29+


## How to use

Expand Down Expand Up @@ -114,54 +109,6 @@ You can add secret variables names there without secret data, just for structure

:warning: **WARNING Do not define secrets (private keys, passwords, tokens, etc.) in committed files, it's not secure!**

### Launch in proxy mode
A proxy mode is useful when you are launching multiply web applications on port 80.

1. Start the nginx-proxy container

<details>
<summary>Nginx-proxy docker-compose.yml file</summary>

```
version: '3.9'
services:
nginx-proxy:
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
environment:
DISABLE_ACCESS_LOGS: 1
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./logs:/var/log/nginx
restart: always
networks:
default:
external:
name: nginx-proxy
```
</details>

[Docker hub Nginx-proxy details](https://hub.docker.com/r/jwilder/nginx-proxy)

2. [Install](#installation) and use the Makefile command to run the proxy mode:

``` bash
make [t=<environment_type>] upp
```

**Examples:**

```bash
make upp
make t=stage upp
make t=prod upp
```

### Production Launch with HTTPS

1. Put your certificate files in `./config/nginx/ssl/` with names <your-app-domain.com>.crt and <your-app-domain.com>.key
Expand All @@ -171,14 +118,13 @@ make t=prod upp
```bash
make up-prod
```
It will up special file `docker-compose.prod.yml` with 80 and your port (most likely 443). The configuration file `/config/nginx/templates/partials/https.conf.template` will also be used instead of `/config/nginx/templates/partials/http.conf.template`
The configuration file `/config/nginx/templates/partials/https.conf.template` will be used instead of `/config/nginx/templates/partials/http.conf.template`

### Makefile commands

- `make secret`
- `make [t=<environment_type>] [s=<command>] up`
- `make [t=<environment_type>] [s=<command>] upd`
- `make [t=<environment_type>] [s=<command>] upp` - `make t=stage s=--build upp`
- `make [s=<command>] up-prod` - production launch with http > https redirect
- `make down` - `docker-compose down -v`
- `make start` - `docker-compose start`
Expand Down Expand Up @@ -276,5 +222,5 @@ To activate backups:

3. If you have more than one database (maybe custom databases), check `mysqldump` command parameters in `./docker/cron/start-backup.sh`

Backups will appear in the `./backups` folder, logs in docker cron container logs
Backups will appear in the `./backups` folder, logs in the docker cron container logs

6 changes: 0 additions & 6 deletions config/environment/.env.main
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ WP_MAX_MEMORY_LIMIT=512M
WP_DISABLE_WP_CRON=1


# Redis
WP_REDIS_HOST=redis
WP_REDIS_PORT=6379
WP_REDIS_PREFIX=wp_redis_6379


# SSH tunnel options
# You can use an SSH tunnel to connect to database from an external app (for example HeidiSQL)
# Uncomment ports directive in database service in docker-compose.yml and use this constant to set up an external app port
Expand Down
16 changes: 7 additions & 9 deletions config/environment/.env.type.dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ WP_ENVIRONMENT_TYPE=development
# App info
APP_PROTOCOL=http
APP_DOMAIN=your-app-domain.loc
APP_PORT=80
# Use 80 (or 443) port with proxy or if your app is single on server
# Use another unique port if you want URL like http://your-app-domain.com:8080
APP_HTTP_PORT=80
APP_HTTPS_PORT=443
# Use 80 and 443 port if your app is single on server
# For multiply instances use another unique port. Your URL will be like http://your-app-domain.com:8080
# Change only APP_HTTP_PORT if you use `http`, or APP_HTTPS_PORT if you use `https`
#
# If port != 80 and port != 443 WordPress Home url will be with port
# Result URL will be
# if (APP_PORT != 80 && APP_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_PORT
# if (APP_HTTP(S)_PORT != 80 && APP_HTTP(S)_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_HTTP(S)_PORT
# } else {
# URL = $APP_PROTOCOL://$APP_DOMAIN
# }
Expand All @@ -35,10 +37,6 @@ WP_DEBUG_LOG=/var/log/wordpress/debug.log
#AQ_RESIZE_DEBUG


# Redis
WP_REDIS_MAXTTL=1


# Backup database and media files cron job
# Edit file in ./config/crontabs folder to setup backup time
APP_WP_BACKUP_ENABLE=0
Expand Down
16 changes: 7 additions & 9 deletions config/environment/.env.type.prod
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ WP_ENVIRONMENT_TYPE=production
# App info
APP_PROTOCOL=https
APP_DOMAIN=your-app-domain.com
APP_PORT=443
# Use 80 (or 443) port with proxy or if your app is single on server
# Use another unique port if you want URL like http://your-app-domain.com:8080
APP_HTTP_PORT=80
APP_HTTPS_PORT=443
# Use 80 and 443 port if your app is single on server
# For multiply instances use another unique port. Your URL will be like http://your-app-domain.com:8080
# Change only APP_HTTP_PORT if you use `http`, or APP_HTTPS_PORT if you use `https`
#
# If port != 80 and port != 443 WordPress Home url will be with port
# Result URL will be
# if (APP_PORT != 80 && APP_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_PORT
# if (APP_HTTP(S)_PORT != 80 && APP_HTTP(S)_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_HTTP(S)_PORT
# } else {
# URL = $APP_PROTOCOL://$APP_DOMAIN
# }
Expand All @@ -35,10 +37,6 @@ WP_DEBUG_LOG=/var/log/wordpress/debug.log
#AQ_RESIZE_DEBUG


# Redis
WP_REDIS_MAXTTL=3600


# Backup database and media files cron job
# Edit file in ./config/crontabs folder to setup backup time
APP_WP_BACKUP_ENABLE=1
Expand Down
16 changes: 7 additions & 9 deletions config/environment/.env.type.stage
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ WP_ENVIRONMENT_TYPE=staging
# App info
APP_PROTOCOL=http
APP_DOMAIN=stage.your-app-domain.com
APP_PORT=80
# Use 80 (or 443) port with proxy or if your app is single on server
# Use another unique port if you want URL like http://your-app-domain.com:8080
APP_HTTP_PORT=80
APP_HTTPS_PORT=443
# Use 80 and 443 port if your app is single on server
# For multiply instances use another unique port. Your URL will be like http://your-app-domain.com:8080
# Change only APP_HTTP_PORT if you use `http`, or APP_HTTPS_PORT if you use `https`
#
# If port != 80 and port != 443 WordPress Home url will be with port
# Result URL will be
# if (APP_PORT != 80 && APP_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_PORT
# if (APP_HTTP(S)_PORT != 80 && APP_HTTP(S)_PORT != 443 ) {
# URL = $APP_PROTOCOL://$APP_DOMAIN:$APP_HTTP(S)_PORT
# } else {
# URL = $APP_PROTOCOL://$APP_DOMAIN
# }
Expand All @@ -35,10 +37,6 @@ WP_DEBUG_LOG=/var/log/wordpress/debug.log
#AQ_RESIZE_DEBUG


# Redis
WP_REDIS_MAXTTL=3600


# Backup database and media files cron job
# Edit file in ./config/crontabs folder to setup backup time
APP_WP_BACKUP_ENABLE=1
Expand Down
8 changes: 4 additions & 4 deletions config/nginx/templates/partials/http.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# http://www > http://non-www redirect
server {
listen ${APP_PORT};
listen [::]:${APP_PORT};
listen ${APP_HTTP_PORT};
listen [::]:${APP_HTTP_PORT};
server_name www.${APP_DOMAIN};

include /etc/nginx/conf.d/partials/logs.conf;
Expand All @@ -15,8 +15,8 @@ server {
}

server {
listen ${APP_PORT};
listen [::]:${APP_PORT};
listen ${APP_HTTP_PORT};
listen [::]:${APP_HTTP_PORT};
server_name ${APP_DOMAIN};

root /var/www/html;
Expand Down
12 changes: 6 additions & 6 deletions config/nginx/templates/partials/https.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# http > https redirect. 80 port should be open
# http://www > https://non-www redirect
server {
listen 80;
listen [::]:80;
listen ${APP_HTTP_PORT};
listen [::]:${APP_HTTP_PORT};
server_name ${APP_DOMAIN} www.${APP_DOMAIN};

include /etc/nginx/conf.d/partials/logs.conf;
Expand All @@ -17,8 +17,8 @@ server {

# https://www > https://non-www redirect
server {
listen ${APP_PORT} ssl http2;
listen [::]:${APP_PORT} ssl http2;
listen ${APP_HTTPS_PORT} ssl http2;
listen [::]:${APP_HTTPS_PORT} ssl http2;
server_name www.${APP_DOMAIN};

include /etc/nginx/conf.d/partials/ssl.conf;
Expand All @@ -30,8 +30,8 @@ server {

# Main directive
server {
listen ${APP_PORT} ssl http2;
listen [::]:${APP_PORT} ssl http2;
listen ${APP_HTTPS_PORT} ssl http2;
listen [::]:${APP_HTTPS_PORT} ssl http2;
server_name ${APP_DOMAIN};

root /var/www/html;
Expand Down
5 changes: 0 additions & 5 deletions docker-compose.override.yml

This file was deleted.

6 changes: 0 additions & 6 deletions docker-compose.prod.yml

This file was deleted.

18 changes: 0 additions & 18 deletions docker-compose.proxy.yml

This file was deleted.

8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ services:
- database
- wordpress
env_file: .env
ports:
- "${APP_HTTP_PORT}:${APP_HTTP_PORT}"
- "${APP_HTTPS_PORT}:${APP_HTTPS_PORT}"
volumes:
- ./config/nginx/templates:/etc/nginx/templates
- ./config/nginx/ssl:/etc/nginx/ssl:ro
Expand All @@ -53,11 +56,6 @@ services:
# WordPress wp-content folder
- ./wp-content:/var/www/html/wp-content

redis:
image: redis:6.2-alpine
container_name: "${APP_NAME}_redis"
restart: unless-stopped

cron:
build: ./docker/cron
container_name: "${APP_NAME}_cron"
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Supplement to original file
#
FROM nginx:1.20-alpine
FROM nginx:1.21-alpine

RUN apk add --no-cache openssl

Expand Down
Loading

0 comments on commit 5019858

Please sign in to comment.