Skip to content

Commit cb25dcd

Browse files
committed
added localhost and remotehost options and support arch linux(pacman package manager)
1 parent dac019a commit cb25dcd

File tree

4 files changed

+513
-106
lines changed

4 files changed

+513
-106
lines changed

README.md

Lines changed: 136 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
11
# [full stack nginx CakePHP for everyone with docker compose](https://github.com/damalis/full-stack-nginx-cakephp-for-everyone-with-docker-compose)
22

3-
If You want to build a website with CakePHP "basic" at short time;
3+
If You want to build a website with CakePHP "basic" at short time;
44

55
#### Full stack Nginx CakePHP "basic":
6-
<p align="left"> <a href="https://www.cakephp.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/23666?s=200&v=4" alt="cakephp" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.docker.com/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png" alt="docker" width="40" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://mariadb.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/5877084?s=200&v=4" alt="mariadb" height="50" width="50"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.nginx.com" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1412239?s=200&v=4" alt="nginx" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.php.net" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/25158?s=200&v=4" alt="php" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://redis.io" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1529926?s=200&v=4" alt="redis" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="#" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png" alt="Bash" height="50" width="50" /> </a>&nbsp;&nbsp;&nbsp;
7-
<a href="https://www.phpmyadmin.net/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1351977?s=200&v=4" alt="phpmyadmin" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://letsencrypt.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="letsencrypt" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.portainer.io/?hsLang=en" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/22225832?s=200&v=4" alt="portainer" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.offen.dev/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/47735043?s=200&v=4" alt="backup" height="35" width="35"/> </a> </p>
6+
<p align="left"> <a href="https://www.cakephp.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/23666?s=200&v=4" alt="cakephp" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
7+
<a href="https://www.docker.com/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png" alt="docker" width="40" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
8+
<a href="https://mariadb.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/5877084?s=200&v=4" alt="mariadb" height="50" width="50"/> </a>&nbsp;&nbsp;&nbsp;
9+
<a href="https://dev.mysql.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/2452804?s=200&v=4" alt="mysql" height="50" width="50"/> </a>&nbsp;&nbsp;&nbsp;
10+
<a href="https://www.nginx.com" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1412239?s=200&v=4" alt="nginx" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
11+
<a href="https://www.php.net" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/25158?s=200&v=4" alt="php" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
12+
<a href="https://redis.io" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1529926?s=200&v=4" alt="redis" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
13+
<a href="https://www.phpmyadmin.net/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1351977?s=200&v=4" alt="phpmyadmin" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
14+
<a href="https://letsencrypt.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="letsencrypt" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
15+
<a href="https://certbot.eff.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="certbot" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
16+
<a href="https://www.portainer.io/?hsLang=en" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/22225832?s=200&v=4" alt="portainer" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
17+
<a href="https://docs.docker.com/compose/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/docker/compose/v2/logo.png" alt="docker compose" width="40" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
18+
<a href="https://www.gnu.org/software/bash/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png" alt="Bash" height="40" width="40" /> </a>&nbsp;&nbsp;&nbsp;
19+
<a href="https://www.offen.dev/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/47735043?s=200&v=4" alt="backup" height="35" width="35"/> </a> </p>
820

921
Plus, manage docker containers with Portainer.
1022

23+
#### Supported CPU architectures:
24+
<p align="left"> arm64/aarch64, x86-64 </p>
25+
26+
#### Supported Linux Package Manage Systems:
27+
<p align="left"> apk, dnf, yum, apt/apt-get, zypper, pacman </p>
28+
29+
#### Supported Linux Operation Systems:
30+
<p align="left"> <a href="https://alpinelinux.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/7600810?s=200&v=4" alt="alpine linux" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
31+
<a href="https://fedoraproject.org/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/e6b1e7f0fb8d0bf920bd719c7289243138bdc1b4/topics/fedora/fedora.png" alt="fedora" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
32+
<a href="https://www.centos.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/79192?s=200&v=4" alt="centos" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
33+
<a href="https://www.debian.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1854028?s=200&v=4" alt="debian" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
34+
<a href="https://ubuntu.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/4604537?s=200&v=4" alt="ubuntu" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
35+
<a href="https://www.raspberrypi.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1294177?s=200&v=4" alt="ubuntu" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
36+
<a href="https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/33972111?s=200&v=4" alt="redhat on s390x (IBM Z)" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
37+
<a href="https://www.suse.com/products/server/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/623819?s=200&v=4" alt="opensuse on s390x (IBM Z)" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
38+
<a href="https://archlinux.org/" target="_blank" rel="noreferrer"> <img src="https://gitlab.archlinux.org/uploads/-/system/group/avatar/23/iconfinder_archlinux_386451.png?width=48" alt="arch linux" height="40" width="40"/> </a> </p>
39+
40+
##### Note: Fedora 37, 39 and alpine linux x86-64 compatible, could not try sles IBM Z s390x, rhel IBM Z s390x and raspberrypi.
41+
1142
#### With this project you can quickly run the following:
1243

1344
- [CakePHP](https://github.com/cakephp/app) - [php-fpm](https://hub.docker.com/_/php?tab=tags&page=1&name=fpm)
1445
- [webserver (nginx)](https://hub.docker.com/_/nginx)
1546
- [certbot (letsencrypt)](https://hub.docker.com/r/certbot/certbot)
1647
- [phpMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/)
17-
- [database](https://hub.docker.com/_/mariadb)
48+
- [databaseMariadb](https://hub.docker.com/_/mariadb) [databaseMysql](https://hub.docker.com/_/mysql)
1849
- [redis](https://hub.docker.com/_/redis)
1950
- [backup](https://hub.docker.com/r/offen/docker-volume-backup)
2051

@@ -41,7 +72,7 @@ Create rules to open ports to the internet, or to a specific IPv4 address or ran
4172
- [Webserver](#webserver)
4273
- [Redis](#redis)
4374
- [phpMyAdmin](#phpmyadmin)
44-
- [backup](#backup)
75+
- [backup](#backup)
4576

4677
## Automatic
4778

@@ -63,19 +94,21 @@ chmod +x install.sh
6394

6495
## Requirements
6596

66-
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine.
97+
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine and require up to 2 GB of RAM.
6798

6899
- [How install docker](https://docs.docker.com/engine/install/)
69100
- [How install docker compose](https://docs.docker.com/compose/install/)
70101

71-
Clone this repository or copy the files from this repository into a new folder. In the **docker-compose.yml** file you may change the database from MariaDB to MySQL.
102+
Clone this repository or copy the files from this repository into a new folder.
72103

73104
Make sure to [add your user to the `docker` group](https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user).
74105

75-
## Manual
106+
## Manual
107+
76108
### Configuration
77109

78110
download with
111+
79112
```
80113
git clone https://github.com/damalis/full-stack-nginx-cakephp-for-everyone-with-docker-compose.git
81114
```
@@ -92,28 +125,40 @@ Copy the example environment into `.env`
92125
cp env.example .env
93126
```
94127

95-
Edit the `.env` file to change values of ```LOCAL_TIMEZONE```, ```DOMAIN_NAME```, ```DIRECTORY_PATH```, ```LETSENCRYPT_EMAIL```, ```DB_USER```, ```DB_PASSWORD```, ```DB_NAME```, ```MYSQL_ROOT_PASSWORD```, ```PMA_CONTROLUSER```, ```PMA_CONTROLPASS```, ```PMA_HTPASSWD_USERNAME``` and ```PMA_HTPASSWD_PASSWORD```.
128+
Edit the `.env` file to change values of ```LOCAL_TIMEZONE```, ```DOMAIN_NAME```, ```DIRECTORY_PATH```, ```LETSENCRYPT_EMAIL```, ```DB_USER```, ```DB_PASSWORD```, ```DB_NAME```, ```MYSQL_ROOT_PASSWORD```, ```DATABASE_IMAGE_NAME```, ```DATABASE_CONT_NAME```, ```DATABASE_PACKAGE_MANAGER```, ```DATABASE_ADMIN_COMMANDLINE```, ```PMA_CONTROLUSER```, ```PMA_CONTROLPASS```, ```PMA_HTPASSWD_USERNAME```, ```PMA_HTPASSWD_PASSWORD``` and ```SSL_SNIPPET```.
96129

97130
LOCAL_TIMEZONE=[to see local timezones](https://docs.diladele.com/docker/timezones.html)
98131

99-
DIRECTORY_PATH=```pwd``` at command line
132+
DIRECTORY_PATH=```pwd``` at command line\
133+
DATABASE_IMAGE_NAME=```mariadb``` or ```mysql```\
134+
DATABASE_CONT_NAME=```mariadb```, ```mysql``` or ```custom name```\
135+
DATABASE_PACKAGE_MANAGER=```apt-get update && apt-get install -y gettext-base``` for mariadb, ```microdnf install -y gettext``` for mysql\
136+
DATABASE_ADMIN_COMMANDLINE=```mariadb-admin``` for mariadb, ```mysqladmin``` for mysql\
137+
SSL_SNIPPET=```echo 'Generated Self-signed SSL Certificate at localhost'``` for localhost\
138+
SSL_SNIPPET=```certbot certonly --webroot --webroot-path /tmp/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email ${LETSENCRYPT_EMAIL} -d ${DOMAIN_NAME} -d www.${DOMAIN_NAME}``` for remotehost
100139

101140
and
102141

103142
```
104143
cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
105144
```
106-
107145
change example.com to your domain name in ```./phpmyadmin/apache2/sites-available/default-ssl.conf``` file.
108146

147+
```
148+
cp ./database/phpmyadmin/sql/create_tables.sql.template.example ./database/phpmyadmin/sql/create_tables.sql.template
149+
```
150+
change pma_controluser and db_authentication_password in ```./database/phpmyadmin/sql/create_tables.sql.template``` file.
151+
109152
### Installation
110153

111154
Firstly: will create external volume
112155

113156
```
114-
docker volume create --driver local --opt type=none --opt device=${DIRECTORY_PATH}/certbot --opt o=bind certbot-etc
157+
docker volume create --driver local --opt type=none --opt device=${PWD}/certbot --opt o=bind certbot-etc
115158
```
116159

160+
for localhost ssl: Generate Self-signed SSL Certificate with guide [mkcert repository](https://github.com/FiloSottile/mkcert).
161+
117162
```
118163
docker compose up -d
119164
```
@@ -133,6 +178,7 @@ For convenience you may add a new entry into your hosts file.
133178
```
134179
docker compose -f portainer-docker-compose.yml -p portainer up -d
135180
```
181+
136182
manage docker with [Portainer](https://www.portainer.io/) is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API.
137183

138184
You can also visit `https://example.com:9001` to access portainer after starting the containers.
@@ -171,7 +217,8 @@ To stop and remove all the containers use the `down` command:
171217
docker compose down
172218
```
173219

174-
to remove portainer and the other containers
220+
to remove portainer and the other containers:
221+
175222
```
176223
docker rm -f $(docker ps -a -q)
177224
```
@@ -182,17 +229,38 @@ Use `-v` if you need to remove the database volume which is used to persist the
182229
docker compose down -v
183230
```
184231

185-
to remove external certbot-etc and portainer and the other volumes
232+
to remove external certbot-etc and portainer and the other volumes:
186233

187234
```
188235
docker volume rm $(docker volume ls -q)
189236
```
190237

191-
to remove portainer and the other images
238+
Delete all images, containers, volumes, and networks that are not associated with a container (dangling):
239+
240+
```
241+
docker system prune
242+
```
243+
244+
To additionally remove any stopped containers and all unused images (not just dangling ones), add the -a flag to the command:
245+
246+
```
247+
docker system prune -a
248+
```
249+
250+
to remove portainer and the other images:
251+
192252
```
193253
docker rmi $(docker image ls -q)
194254
```
195255

256+
### Logs containers
257+
258+
To fetch the logs of a container.
259+
260+
```
261+
docker container logs container_name_or_id
262+
```
263+
196264
### Project from existing source
197265

198266
Copy all files into a new directory:
@@ -238,9 +306,59 @@ add or remove code in the ```./webserver/templates/nginx.conf.template``` file f
238306

239307
#### Redis
240308

241-
see [Redis Cache](https://book.cakephp.org/4/en/core-libraries/caching.html#redisengine-options) options and must add below code to config file.
242-
243-
modify redis cache configuration values in the ```/app/basic/config/app_local.php``` file.
309+
see [Redis Cache](https://book.cakephp.org/5/en/core-libraries/caching.html#redisengine-options) options and must add below code to config file.
310+
311+
```
312+
/**
313+
* Configure the cache adapters.
314+
*/
315+
'Cache' => [
316+
'default' => [
317+
'className' => 'Redis',
318+
'path' => CACHE,
319+
'password' => false,
320+
'server' => 'redis',
321+
'port' => 6379,
322+
],
323+
324+
/**
325+
* Configure the cache used for general framework caching.
326+
* Translation cache files are stored with this configuration.
327+
*/
328+
'_cake_core_' => [
329+
'className' => 'Redis',
330+
'prefix' => 'myapp_cake_core_',
331+
'path' => CACHE . 'persistent/',
332+
'serialize' => true,
333+
'duration' => '+2 minutes',
334+
'server' => 'redis',
335+
'port' => 6379,
336+
'password' => false,
337+
],
338+
339+
/**
340+
* Configure the cache for model and datasource caches. This cache
341+
* configuration is used to store schema descriptions, and table listings
342+
* in connections.
343+
*/
344+
'_cake_model_' => [
345+
'className' => 'Redis',
346+
'prefix' => 'myapp_cake_model_',
347+
'path' => CACHE . 'models/',
348+
'serialize' => true,
349+
'duration' => '+2 minutes',
350+
'server' => 'redis',
351+
'port' => 6379,
352+
'password' => false,
353+
],
354+
],
355+
```
356+
357+
modify redis cache configuration values in the ```./cakephp/config/app_local.php``` file.
358+
359+
### DebugKit
360+
361+
[book.cakephp.org/debugkit/5/en/index.html#configuration](https://book.cakephp.org/debugkit/5/en/index.html#configuration)
244362

245363
### phpMyAdmin
246364

0 commit comments

Comments
 (0)