From ef0a8c70f88611333b979614bece80da0ed0201c Mon Sep 17 00:00:00 2001 From: "KosM [Office]" Date: Fri, 1 Oct 2021 10:56:06 +0300 Subject: [PATCH 1/4] added .env to load secreted to docker all from one place. updated instructions to generate ssl keys also. --- README.md | 2 ++ env.sample | 5 +++++ nginx/certs/README.md | 11 +++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 env.sample diff --git a/README.md b/README.md index 19ea0a63..df523e3d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Next, navigate in your terminal to the directory you cloned this, and spin up th After that completes, follow the steps from the [src/README.md](src/README.md) file to get your WordPress installation added in (or create a new blank one). +Copy env.sample to .env and setup your secrets there. + Bringing up the Docker Compose network with `site` instead of just using `up`, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed: - **nginx** - `:80` diff --git a/env.sample b/env.sample new file mode 100644 index 00000000..b0dc7343 --- /dev/null +++ b/env.sample @@ -0,0 +1,5 @@ +PROJECT_NAME=project1 +DB_NAME=db_name +DB_USER=wp +DB_PASSWORD=secret +DB_ROOT_PASSWORD=secret \ No newline at end of file diff --git a/nginx/certs/README.md b/nginx/certs/README.md index ffc020a7..8463ed08 100644 --- a/nginx/certs/README.md +++ b/nginx/certs/README.md @@ -1,5 +1,12 @@ ## Add local certificates here to enable https -I personally like using [mkcert]() for this. +I personally like using [mkcert](https://github.com/FiloSottile/mkcert) for this. -Follow the installation instructions, then `cd` to this directory and use `mkcert` with the local domain name of your choosing. \ No newline at end of file +Follow the installation instructions, then `cd` to this directory and use `mkcert` with the local domain name of your choosing. + +After installation of mkcert + +``` +cd ./nginx/certs +mkcert -key-file wordpress-docker.test-key.pem -cert-file wordpress-docker.test.pem localhost *.localhost +``` \ No newline at end of file From 8f13b729e364536fae86d5a7009f063aa6dbdb59 Mon Sep 17 00:00:00 2001 From: "KosM [Office]" Date: Fri, 1 Oct 2021 10:57:06 +0300 Subject: [PATCH 2/4] added env project name to container names to avoid conflicts to similar projects --- docker-compose.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1b7c8f59..ba48832d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: build: context: . dockerfile: nginx.dockerfile - container_name: nginx + container_name: nginx${PROJECT_NAME} ports: - 80:80 - 443:443 @@ -22,15 +22,15 @@ services: mysql: image: mysql:5.7.29 - container_name: mysql + container_name: mysql${PROJECT_NAME} restart: always ports: - 3306:3306 environment: - MYSQL_DATABASE: wp - MYSQL_USER: wp - MYSQL_PASSWORD: secret - MYSQL_ROOT_PASSWORD: secret + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD SERVICE_TAGS: dev SERVICE_NAME: mysql networks: @@ -40,7 +40,7 @@ services: build: context: . dockerfile: php.dockerfile - container_name: php + container_name: php_${PROJECT_NAME} volumes: - ./wordpress:/var/www/html:delegated networks: @@ -50,7 +50,7 @@ services: build: context: . dockerfile: php.dockerfile - container_name: wp + container_name: wp${PROJECT_NAME} entrypoint: ['wp', '--allow-root'] volumes: - ./wordpress:/var/www/html:delegated From 9fbebc13a21b2c3b796fe4f147a5e1fd2217e2c5 Mon Sep 17 00:00:00 2001 From: "KosM [Office]" Date: Fri, 1 Oct 2021 11:21:27 +0300 Subject: [PATCH 3/4] added and load php.ini --- docker-compose.yml | 1 + php/php.ini | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 php/php.ini diff --git a/docker-compose.yml b/docker-compose.yml index ba48832d..35a99c57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,6 +43,7 @@ services: container_name: php_${PROJECT_NAME} volumes: - ./wordpress:/var/www/html:delegated + - ./php/php.ini:/usr/local/etc/php/php.ini networks: - wordpress diff --git a/php/php.ini b/php/php.ini new file mode 100644 index 00000000..2ea10587 --- /dev/null +++ b/php/php.ini @@ -0,0 +1,3 @@ +upload_max_filesize = 132M +post_max_size = 64M +memory_limit = 128M \ No newline at end of file From 429d7ab18852af03b4ac93840d336467c7b52636 Mon Sep 17 00:00:00 2001 From: Kos-M <46938390+Kos-M@users.noreply.github.com> Date: Wed, 21 Dec 2022 09:04:41 +0200 Subject: [PATCH 4/4] add unserscore in prefix container names before env variables --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 35a99c57..d356c76f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: build: context: . dockerfile: nginx.dockerfile - container_name: nginx${PROJECT_NAME} + container_name: nginx_${PROJECT_NAME} ports: - 80:80 - 443:443 @@ -22,7 +22,7 @@ services: mysql: image: mysql:5.7.29 - container_name: mysql${PROJECT_NAME} + container_name: mysql_${PROJECT_NAME} restart: always ports: - 3306:3306 @@ -51,9 +51,9 @@ services: build: context: . dockerfile: php.dockerfile - container_name: wp${PROJECT_NAME} + container_name: wp_${PROJECT_NAME} entrypoint: ['wp', '--allow-root'] volumes: - ./wordpress:/var/www/html:delegated networks: - - wordpress \ No newline at end of file + - wordpress