Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.

Commit 2377219

Browse files
committed
version from gitlab
1 parent 49ba6c8 commit 2377219

20 files changed

+383
-71
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MYSQL_DATABASE=root
1111
#=========================#
1212
WORDPRESS_PORT=9344
1313
PHPMYADMIN_PORT=9335
14-
14+
MYSQL_PORT=9336
1515
#=========================#
1616
# >--LIVE--< #
1717
#=========================#

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
.terraform*
33
terraform.tfstate
44
terraform.tfstate.backup
5-
var
65
terraform.tfvars

.gitlab-ci.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
image: quay.io/project-wordpress/docker:18.04-compose
2+
3+
services:
4+
- docker:18.04-dind
5+
6+
#cache: &cache
7+
# key: ${CI_COMMIT_REF_SLUG}
8+
# paths:
9+
# - ./var/
10+
11+
#variables:
12+
# DOCKER_HOST: tcp://localhost:2375
13+
# DOCKER_DRIVER: overlay2
14+
15+
test:
16+
stage: test
17+
# cache:
18+
# <<: *cache
19+
20+
before_script:
21+
- source .env
22+
- echo "127.0.0.1 ${DOMAIN_NAME}" | tee -a /etc/hosts
23+
- chmod +x ./run_tests.sh
24+
# - export gid=82
25+
# - export uid=82
26+
# - export user=www-data
27+
# - addgroup --gid "$gid" "$user" \
28+
# && adduser \
29+
# --disabled-password \
30+
# --gecos "" \
31+
# --home "$(pwd)" \
32+
# --ingroup "$user" \
33+
# --no-create-home \
34+
# --uid "$uid" \
35+
# "$user"
36+
# - chown -R 82:82 ./var
37+
script:
38+
- ./run_tests.sh
39+
after_script:
40+
- docker ps
41+
- docker stats --no-stream
42+
- ls -al ./var/www/html/wp-content
43+
- ls -al ./var/www/html/
44+
- docker-compose logs
45+
#
46+
#docker-build-master:
47+
# stage: build
48+
# image: docker:18.04
49+
# before_script:
50+
# - docker login -u "$CI_REGISTRY_user" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
51+
# variables:
52+
# MYSQL_IMAGE: $CI_REGISTRY_IMAGE/mysql:latest
53+
# WORDPRESS_IMAGE: $CI_REGISTRY_IMAGE/wordpress:latest
54+
# WPCLI_IMAGE: $CI_REGISTRY_IMAGE/wp-cli:latest
55+
# NGINX_IMAGE: $CI_REGISTRY_IMAGE/nginx:latest
56+
# script:
57+
# - docker pull $MYSQL_IMAGE || true
58+
# - docker pull $WORDPRESS_IMAGE || true
59+
# - docker pull $WPCLI_IMAGE || true
60+
# - docker pull $NGINX_IMAGE || true
61+
# - docker build --cache-from $MYSQL_IMAGE -t $MYSQL_IMAGE ./mysql/
62+
# - docker build --cache-from $WORDPRESS_IMAGE -t $WORDPRESS_IMAGE ./wordpress/
63+
# - docker build --cache-from $WPCLI_IMAGE -t $WPCLI_IMAGE ./wp-cli/
64+
# - docker build --cache-from $NGINX_IMAGE -t $NGINX_IMAGE ./nginx/
65+
# - docker push $MYSQL_IMAGE
66+
# - docker push $WORDPRESS_IMAGE
67+
# - docker push $WPCLI_IMAGE
68+
# - docker push $NGINX_IMAGE
69+
# only:
70+
# - master

COMMANDS.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@madmath03
2+
With this command you can still connect to all stacks if you have consistent naming, just change `$NAME`
3+
````bash
4+
NAME=wpdev && docker run --rm -it \
5+
--volumes-from="${NAME}_wordpress_1" \
6+
--network="${NAME}_default" \
7+
-e WORDPRESS_HOST=wordpress:9000 \
8+
-u 33 \
9+
test \
10+
\
11+
/bin/bash
12+
Success: WordPress is up to date.
13+
````
14+
15+
Or if you have non-consistent naming place `.env` file in your `docker-compose.yaml` folder, `docker-compose` will read it automatically:
16+
````bash
17+
---------- 420 buk 345233 236 Jan 26 14:06 .env
18+
---------- 420 buk 345233 124 Jan 26 14:06 docker-compose.yaml
19+
````
20+
````env
21+
# .env
22+
NETWORK_NAME=mynetwork
23+
WORDPRESS_CONTAINER=mycontainer
24+
````
25+
````yaml
26+
# docker-compose.yaml
27+
networks:
28+
test:
29+
name: $NETWORK_NAME
30+
31+
services:
32+
33+
wordpress:
34+
container_name: $WORDPRESS_CONTAINER
35+
networks:
36+
- test
37+
38+
mysql:
39+
networks:
40+
- test
41+
````
42+
And then run:
43+
```bash
44+
source .env && \
45+
docker run -it \
46+
--volumes-from="${WORDPRESS_CONTAINER}" \
47+
--network="${NETWORK_NAME}" \
48+
wordpress:cli-php7.4 \
49+
\
50+
/bin/bash -c "wp core update"
51+
```
52+
53+
To use `name` in `networks` you have to use `docker-compose >= 3.4`
54+
Also, keep in mind:
55+
56+
> Values in the shell take precedence over those specified in the .env file. If you set TAG to a different value in your shell, the substitution in image uses that instead
57+
58+
59+
* See https://docs.docker.com/v17.12/compose/environment-variables/#set-environment-variables-with-docker-compose-run

LIVEEDIT.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
1. Install Live Edit plugin.
2+
2. If you want to use your extensions in chrome, you have to use [chrome extension](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji?hl=en) (see picture 1 "User JetBrains IDE Support")
3+
4+
![alt text](help/phpstorm64_KCvQaoAueV.png)
5+
![alt text](help/phpstorm64_8gyuPN29dM.png)
6+
![alt text](help/phpstorm64_X4S09Qre5h.png)
7+
8+
3. `docker-compose up` to run your application.

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ copy-db:
4444
BACKUP_FILE=$(shell make db-export | tail -1);\
4545
cp ./var/backups/$$BACKUP_FILE ./mysql/docker-entrypoint-initdb.d
4646

47+
.PHONY: wp
48+
wp:
49+
${DEV} run wp-cli $(args)
4750
#file=connect
4851
#folder=./tests/python
4952
#args="localhost ${WORDPRESS_PORT} / 200"
@@ -60,6 +63,10 @@ tests:
6063
crawl-local:
6164
make folder=./tests/python file=crawl test args="http://localhost:${WORDPRESS_PORT}"
6265

66+
.PHONY: wp-cli-up
67+
wp-cli-up: ## wp-cli up build
68+
${DEV} up --build wp-cli
69+
6370
.PHONY: help
6471
help:
6572
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

README.md

+58-38
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,74 @@
33

44
Local stack for developing [`wordpress`](https://wordpress.org/)
55

6-
Future goal of this project is to bring painless developing experience alongside production ready containers ready to be deploy to plain `docker` or `kubernetes` via `CI/CD` pipelines.
7-
```bash
8-
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
9-
10-
da0e07d3dcb3 nginx_1 0.00% 2.82MiB / 7.79GiB 0.04% 490kB / 1.01MB 0B / 0B 3
6+
There is a lot of files, but you may be interested only in few of them, don't worry!
117

12-
4875a813d4a0 wordpress_1 0.00% 12.78MiB / 7.79GiB 0.16% 603kB / 576kB 0B / 32.8kB 3
13-
14-
7f5cefd9d559 phpmyadmin_1 0.00% 9.32MiB / 7.79GiB 0.12% 210B / 0B 0B / 0B 6
8+
### Usage:
9+
* You can add plugins and themes that you want to be installed automatically in [wpdev.yaml](./var/config/wpdev.yaml) (for now only official plugins and themes can be installed this way using slug)
10+
* Edit [.env](./.env) file to your needs (you may want to change ports if you are working on few project at a time )
11+
* Default themes and plugins that are bundled with wordpress are deleted.
1512

16-
16ce9c05cc74 mysql_1 0.25% 83.1MiB / 7.79GiB 1.04% 146kB / 611kB 0B / 58.2MB 41
13+
To start execute this command:
14+
```bash
15+
docker-compose up
16+
```
17+
* `wordpress` will be live at
18+
```bash
19+
http://localhost:$WORDPRESS_PORT
20+
```
21+
* `phpmyadmin` will be live at
22+
```bash
23+
http://localhost:$PHPMYADMIN_PORT
24+
```
25+
```bash
26+
wordpress_1 | Complete! WordPress has been successfully copied to /var/www/html
27+
wordpress_1 | [28-Jan-2020 13:05:22] NOTICE: fpm is running, pid 1
28+
wordpress_1 | [28-Jan-2020 13:05:22] NOTICE: ready to handle connections
29+
wp-cli_1 | wait-for-it: wordpress:9000 is available after 37 seconds
30+
wp-cli_1 | Developing...
31+
wp-cli_1 | declare -x WORDPRESS_PORT="9344"
32+
wp-cli_1 | Installing wordpress...
33+
mysql_1 | mbind: Operation not permitted
34+
wp-cli_1 | Success: WordPress installed successfully.
35+
wp-cli_1 | Installing plugins...
36+
wp-cli_1 | Installing themes...
37+
wp-cli_1 | Deleting plugins
38+
wp-cli_1 | Deleted 'hello' plugin.
39+
wp-cli_1 | Success: Deleted 1 of 1 plugins.
40+
wp-cli_1 | Deleted 'akismet' plugin.
41+
wp-cli_1 | Success: Deleted 1 of 1 plugins.
42+
wp-cli_1 | Deleting themes
43+
wp-cli_1 | Deleted 'twentynineteen' theme.
44+
wp-cli_1 | Success: Deleted 1 of 1 themes.
45+
wp-cli_1 | Deleted 'twentyseventeen' theme.
46+
wp-cli_1 | Success: Deleted 1 of 1 themes.
47+
wp-cli_1 | Deleted 'twentysixteen' theme.
48+
wp-cli_1 | Success: Deleted 1 of 1 themes.
49+
wp-cli_1 | Installing `theme`
50+
wp-cli_1 | Unpacking the package...
51+
wp-cli_1 | Installing the theme...
52+
wp-cli_1 | Theme installed successfully.
53+
wp-cli_1 | Success: Installed 1 of 1 themes.
54+
wp-cli_1 | Activating all plugins...
55+
wp-cli_1 | Success: No plugins installed.
56+
wp-cli_1 | Activating `theme`
57+
wp-cli_1 | Success: Switched to 'theme' theme.
58+
wp-cli_1 | Rewriting permalinks
59+
wp-cli_1 | Success: Rewrite structure set.
60+
mysql_1 | mbind: Operation not permitted
61+
wp-cli_1 | Success: Rewrite rules flushed.
62+
wp-cli_1 | Visit http://localhost:9344/wp-login.php
1763
```
1864
## Info
19-
* please get involved if you can
65+
* theres `run_tests.sh` or `.gitlab-ci.yml` that can be used to run your tests
2066
* tests are parsing your site and checking if everything responds with status code `200`, to change that behaviour see [this file](./tests/python/crawl.py)
2167
* static files are handled by `nginx`
2268
* wp-cli will handle changing `SITE_URL` based on your `.env` settings
23-
* this stack can be easy deployed live using `make deploy`
2469

2570
### Requirements:
2671
* [docker](https://www.docker.com/)
2772
* [docker-compose](https://docs.docker.com/compose/)
2873

29-
### Usage:
30-
* Edit [.env](./.env) file to your needs and run:
31-
```bash
32-
docker-compose up
33-
```
34-
* Wordpress will be automatically installed your site should be live at `
35-
http://localhost:$WORDPRESS_PORT`
36-
```bash
37-
wordpress_1 | Complete! WordPress has been successfully copied to /var/www/html
38-
wordpress_1 | [25-Jan-2020 22:46:56] NOTICE: fpm is running, pid 1
39-
wordpress_1 | [25-Jan-2020 22:46:56] NOTICE: ready to handle connections
40-
wp-cli_1 | wait-for-it: wordpress:9000 is available after 35 seconds
41-
wp-cli_1 | Developing...
42-
wp-cli_1 | Installing wordpress...
43-
wp-cli_1 | Success: WordPress installed successfully.
44-
wp-cli_1 | Visit http://localhost:9344
45-
wpdev_wp-cli_1 exited with code 0
46-
```
47-
* phpmyadmin will be live at
48-
```bash
49-
http://localhost:$PHPMYADMIN_PORT
50-
```
5174
* to backup your database into `./var/backups` run:
5275
```bash
5376
make db-export
@@ -57,11 +80,11 @@ make db-export
5780
make copy-db
5881
```
5982
## Tests
60-
* while running `make tests` or directly calling `run_tests.sh` live deployment will be tested too, it means that your host should resolve `$DOMAIN_NAME` from `.env` file
6183
* to run a simle crawling test checking for status code 200 on your local development run
6284
```bash
6385
make crawl-local
6486
```
87+
6588
```bash
6689
PARSED
6790
{
@@ -142,11 +165,8 @@ make copy-db
142165
# todo & needs fixing
143166
* design db migration schemas and production database separation
144167
* make http benchmarking
145-
* lower mysql ram usage (currently 80MiB)
146-
* urls like `localhost:9333/asdASDa/435/345/345/345` redirect to `homepage` why?
147-
* modify `wp-cli` to allow custom setup (activating plugins etc.)
168+
* lower mysql and wordpress ram usage (currently 20MiB and 80MiB but after installing theme up to 300MiB and 400MiB?????)
148169
* allow `crawl.py` allowed rules to be specified in a file
149170
* create solid `nginx` configuration
150171
* test file permissions and sensitive files
151172
* mysql 8.0.18 gives `mbind: Operation not permitted`
152-
* test db import export

docker-compose.override.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ services:
2323
volumes:
2424
- "./var/www/html:/var/www/html"
2525
- "./var/backups:/backups"
26+
- "./var/config/:/apps/config/"
2627

2728
phpmyadmin:
2829
depends_on:

docker-compose.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: '3.6'
33
services:
44

55
nginx:
6-
restart: unless-stopped
76
depends_on:
87
- wordpress
98
build:
@@ -12,7 +11,6 @@ services:
1211
- "./var/www/html:/var/www/html"
1312

1413
wordpress:
15-
restart: unless-stopped
1614
depends_on:
1715
- mysql
1816
build:
@@ -22,16 +20,19 @@ services:
2220
WORDPRESS_DB_USER: "root"
2321
WORDPRESS_DB_PASSWORD: ${MYSQL_ROOT_PASSWORD}
2422
WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
23+
WORDPRESS_DEBUG: 1
24+
WORDPRESS_CONFIG_EXTRA: |
25+
define( 'UPLOADS', 'wp-content/uploads' );
2526
volumes:
2627
- "./var/www/html:/var/www/html"
2728

2829
mysql:
29-
restart: unless-stopped
3030
build:
3131
context: ./mysql
32+
ports:
33+
- ${MYSQL_PORT}:3306
3234
environment:
3335
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
3436
MYSQL_DATABASE: ${MYSQL_DATABASE}
3537
volumes:
3638
- "./var/mysql:/var/lib/mysql"
37-
- "./var/backups:/backups"

help/phpstorm64_8gyuPN29dM.png

29.2 KB
Loading

help/phpstorm64_KCvQaoAueV.png

28.4 KB
Loading

help/phpstorm64_X4S09Qre5h.png

1.93 KB
Loading

0 commit comments

Comments
 (0)