Skip to content

Commit 157eb47

Browse files
committed
Update GitHub Workflow
1 parent 3b9f744 commit 157eb47

File tree

11 files changed

+127
-54
lines changed

11 files changed

+127
-54
lines changed

.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
DB_NAME=wordpress
2-
DB_USER=dbadmin
3-
DB_PASS=secret
1+
# MYSQL_ROOT_PASSWORD=rootpass
2+
DB_DATABASE=wordpress
3+
DB_USERNAME=dbadmin
4+
DB_PASSWORD=secret

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@
4141
*.ttf binary
4242
*.woff binary
4343
*.woff2 binary
44+
*.xslx binary
4445

4546
# Exclude unused files
47+
/.github export-ignore
48+
/test export-ignore
4649
/.editorconfig export-ignore
4750
/.gitattributes export-ignore
4851
/.gitignore export-ignore
4952
/.travis.yml export-ignore
5053
/CHANGELOG.md export-ignore
54+
/CONTRIBUTING.md export-ignore

README.md renamed to .github/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ This is what each item is for:
1717
* `bin/` – Useful command-line scripts.
1818
* `data/` – MySQL dump files go here.
1919
* `docker/` – Files required by the Docker setup are in this directory.
20-
* `README.md` – Every project needs a README!
2120
* `docker-compose.yml` – Development orchestration config file.
2221
* `Dockerrun.aws.json` - Elastic Beanstalk config file.
2322

@@ -71,10 +70,10 @@ This is to ensure proper review of all the code.
7170

7271
Fork the project, create a feature branch, and send a pull request.
7372

74-
If you would like to help take a look at the [list of issues](https://github.com/oanhnn/example-nginx-proxy-auto-ssl/issues).
73+
If you would like to help take a look at the [list of issues](https://github.com/oanhnn/example-wordpress-with-docker/issues).
7574

7675
## License
7776

7877
This project is released under the MIT License.
79-
Copyright © 2019 [Oanh Nguyen](https://github.com/oanhnn)
80-
Please see [License File](https://github.com/oanhnn/example-nginx-proxy-auto-ssl/blob/master/LICENSE) for more information.
78+
Copyright © 2020 [Oanh Nguyen](https://github.com/oanhnn)
79+
Please see [License File](https://github.com/oanhnn/example-wordpress-with-docker/blob/master/LICENSE) for more information.

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
# Test every Tuesday at at 8:35 AM UTC
5+
schedule:
6+
- cron: "35 8 * * 2"
7+
8+
# Test when push to main branch
9+
push:
10+
branches:
11+
- master
12+
- develop
13+
14+
# For all PRs to the main branch run the tests
15+
pull_request:
16+
branches:
17+
- master
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Setting up Docker Buildx
27+
id: buildx
28+
uses: docker/setup-buildx-action@v1
29+
30+
- name: Cache Docker layers
31+
uses: actions/cache@v2
32+
with:
33+
path: /tmp/.buildx-cache
34+
key: ${{ runner.os }}-buildx-${{ github.sha }}
35+
restore-keys: ${{ runner.os }}-buildx-
36+
37+
- name: Build test
38+
id: docker_test
39+
uses: docker/build-push-action@v2
40+
with:
41+
builder: ${{ steps.buildx.outputs.name }}
42+
cache-from: type=local,src=/tmp/.buildx-cache
43+
cache-to: type=local,dest=/tmp/.buildx-cache
44+
context: ./docker/wordpress
45+
file: ./docker/wordpress/Dockerfile
46+
pull: true
47+
load: true
48+
tags: wordpress_app
49+
50+
- name: Setup docker-compose
51+
run: cp ./.env.example ./.env
52+
53+
- name: Run with docker
54+
run: |
55+
docker-compose up -d
56+
sleep 15
57+
docker-compose ps
58+
docker-compose exec -T wp wp --info
59+
curl --fail -s http://127.0.0.1/wp-admin/install.php || exit 1
60+
docker-compose down

Dockerrun.aws.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"containerDefinitions": [
1818
{
1919
"name": "wp",
20-
"image": "wordpress:5-php7.3-fpm-alpine",
20+
"image": "wordpress:php7.4-fpm-alpine",
2121
"essential": true,
2222
"environment": [
2323
{
@@ -65,15 +65,15 @@
6565
"links": [
6666
"wp"
6767
],
68-
"volumesFrom": [
69-
{
70-
"sourceContainer": "wp"
71-
}
72-
],
7368
"mountPoints": [
69+
{
70+
"sourceVolume": "app-source",
71+
"containerPath": "/var/www/html",
72+
"readOnly": true
73+
},
7474
{
7575
"sourceVolume": "web-config",
76-
"containerPath": "/etc/nginx/conf.d/default",
76+
"containerPath": "/etc/nginx/templates/default.conf.template",
7777
"readOnly": true
7878
},
7979
{
@@ -92,7 +92,7 @@
9292
"localContainerDefinitions": [
9393
{
9494
"name": "db",
95-
"image": "mysql:5.7",
95+
"image": "mysql:8.0",
9696
"essential": true,
9797
"environment": [
9898
{

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Oanh Nguyen <oanhnn.bk@gmail.com>
3+
Copyright (c) 2020 Oanh Nguyen <oanhnn.bk@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

bin/backup-db.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ source "$ROOT_DIR/.env"
66
file="ROOT_DIR/${1:-data/dump-$(date +%Y%m%d-%H%M%S).sql}"
77

88
# Create dump file
9-
cmd='mysqldump -u"$DB_USER" -p"$DB_PASS" "$DB_NAME"'
10-
docker-compose exec db sh -c "$cmd" > $file
9+
cmd='MYSQL_PWD=\$MYSQL_PASSWORD mysqldump -u \$MYSQL_USER \$MYSQL_DATABASE'
10+
docker-compose exec mysql sh -c "$cmd" > $file
1111

1212
# Remove password warning from the file
13-
sed -i '.bak' 1,1d $file && rm "$file.bak"
13+
# sed -i '.bak' 1,1d $file && rm "$file.bak"
1414

1515
# Compressing dump file
1616
gzip $file > $file.gz && rm "$file"

bin/restore-db.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ if [ -z "$file" ]; then
99
exit 1;
1010
fi
1111

12-
# Uncompressing file
13-
14-
1512
# Restore database to db container
16-
cmd='mysql -u"$DB_USER" -p"$DB_PASS" "$DB_NAME"'
17-
docker exec -i $(docker-compose ps -q db) sh -c "$cmd" < $file
13+
cmd='MYSQL_PWD=\$MYSQL_PASSWORD mysql -u \$MYSQL_USER \$MYSQL_DATABASE'
14+
docker-compose exec mysql sh -c "$cmd" < $file

docker-compose.yml

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,56 @@ version: "3.5"
22

33
### Networks ###
44
networks:
5-
default: {}
5+
mysql-net: {}
6+
proxy-net: {}
67

78
### Volumes ###
89
volumes:
9-
db-data: {}
10+
mysql-vol: {}
1011

1112
### Services ###
1213
services:
1314

1415
### Mysql service ###
15-
db:
16-
image: mysql:5.7
16+
mysql:
17+
image: mysql:8.0
18+
command:
19+
- mysqld
20+
- --character-set-server=utf8mb4
21+
- --collation-server=utf8mb4_unicode_ci
1722
environment:
18-
MYSQL_ROOT_PASSWORD: rootpass
19-
MYSQL_DATABASE: ${DB_NAME}
20-
MYSQL_USER: ${DB_USER}
21-
MYSQL_PASSWORD: ${DB_PASS}
23+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpass}
24+
MYSQL_USER: ${DB_USERNAME}
25+
MYSQL_PASSWORD: ${DB_PASSWORD}
26+
MYSQL_DATABASE: ${DB_DATABASE}
2227
networks:
23-
- default
24-
ports:
25-
- 3306:3306
28+
- mysql-net
29+
# ports:
30+
# - 3306:3306
2631
restart: unless-stopped
2732
volumes:
28-
- db-data:/var/lib/mysql
29-
# - init-db:/docker-entrypoint-initdb.d
33+
- mysql-vol:/var/lib/mysql
34+
# - ./initdb:/docker-entrypoint-initdb.d:ro
35+
healthcheck:
36+
test: MYSQL_PWD=$$MYSQL_PASSWORD mysqladmin -u $$MYSQL_USER --silent ping
37+
start_period: 2s
38+
interval: 1s
39+
timeout: 3s
40+
retries: 10
3041

3142
### Wordpress service ###
3243
wp:
44+
image: wordpress_app
3345
build:
3446
context: ./docker/wordpress
3547
dockerfile: Dockerfile
3648
depends_on:
37-
- db
49+
- mysql
3850
environment:
39-
WORDPRESS_DB_NAME: ${DB_NAME}
40-
WORDPRESS_DB_USER: ${DB_USER}
41-
WORDPRESS_DB_PASSWORD: ${DB_PASS}
42-
WORDPRESS_DB_HOST: db
51+
WORDPRESS_DB_NAME: ${DB_DATABASE}
52+
WORDPRESS_DB_USER: ${DB_USERNAME}
53+
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
54+
WORDPRESS_DB_HOST: mysql
4355
WORDPRESS_DB_CHARSET: utf8
4456
# WORDPRESS_DB_COLLATE:
4557
WORDPRESS_TABLE_PREFIX: wp_
@@ -53,7 +65,8 @@ services:
5365
# WORDPRESS_NONCE_SALT:
5466
WORDPRESS_DEBUG: 1
5567
networks:
56-
- default
68+
- mysql-net
69+
- proxy-net
5770
restart: unless-stopped
5871
volumes:
5972
- ./docker/wordpress/php.ini:/usr/local/etc/php/conf.d/dev.ini:ro
@@ -62,16 +75,19 @@ services:
6275
### Web service ###
6376
web:
6477
image: nginx:stable-alpine
65-
# build:
66-
# context: ./docker/nginx
67-
# dockerfile: Dockerfile
6878
depends_on:
6979
- wp
7080
networks:
71-
- default
81+
- proxy-net
7282
restart: unless-stopped
7383
ports:
7484
- 80:80
7585
volumes:
76-
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
86+
- ./docker/nginx/default.conf:/etc/nginx/templates/default.conf.template:ro
7787
- ./app:/var/www/html
88+
healthcheck:
89+
test: curl --fail --silent http://127.0.0.1/_health/nginx || exit 1
90+
start_period: 2s
91+
interval: 1s
92+
timeout: 3s
93+
retries: 10

docker/nginx/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)