Skip to content

Commit 8283d6d

Browse files
committed
Updated README
1 parent a02e01a commit 8283d6d

File tree

1 file changed

+81
-85
lines changed

1 file changed

+81
-85
lines changed

README.md

Lines changed: 81 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,42 @@
88

99
![Laravel Logo](https://garutilorenzo.github.io/images/laravel.png)
1010

11-
#### How to use this repository
12-
13-
There are 3 branch. Each branch contains a different base image.
14-
On each branch then you can find a "build matrix" in build.sh
15-
Switch to the branch with the base image you prefer and build the images, or download images directly from https://hub.docker.com/
16-
17-
The branches are:
18-
19-
* master: official php images
20-
* alpine: official php alpine images
21-
* ubuntu: ubuntu official images + php
22-
23-
on each branch you can find a build.sh. This file builds:
24-
25-
* on the master branch:
26-
* php80: Laravel docker image with official PHP 8.0 and MySQL PDO
27-
* php80-pgsql: Laravel docker image with official PHP 8.0 and PgSQL PDO
28-
* php74: Laravel docker image with official PHP 7.4 and MySQL PDO
29-
* php74-pgsql: Laravel docker image with official PHP 7.4 and PgSQL PDO
30-
* php73: Laravel docker image with official PHP 7.3 and MySQL PDO
31-
* php73-pgsql: Laravel docker image with official PHP 7.3 and PgSQL PDO
32-
* on the alpine branch:
33-
* alpine-php80: Laravel docker image with official PHP 8.0 Alpine and MySQL PDO
34-
* alpine-php80-pgsql: Laravel docker image with official PHP Alpine 8.0 and PgSQL PDO
35-
* alpine-php74: Laravel docker image with official PHP 7.4 Alpine and MySQL PDO
36-
* alpine-php74-pgsql: Laravel docker image with official PHP Alpine 7.4 and PgSQL PDO
37-
* alpine-php73: Laravel docker image with official PHP 7.3 Alpine and MySQL PDO
38-
* alpine-php73-pgsql: Laravel docker image with official PHP Alpine 7.3 and PgSQL PDO
39-
* on the ubuntu branch:
40-
* ubuntu-php80: Laravel docker image with official Ubuntu image + PHP 8.0 and MySQL PDO
41-
* ubuntu-php80-pgsql: Laravel docker image with official Ubuntu image + PHP 8.0 and PgSQL PDO
42-
* ubuntu-php74: Laravel docker image with official Ubuntu image + PHP 7.4 and MySQL PDO
43-
* ubuntu-php74-pgsql: Laravel docker image with official Ubuntu image + PHP 7.4 and PgSQL PDO
44-
* ubuntu-php73: Laravel docker image with official Ubuntu image + PHP 7.3 and MySQL PDO
45-
* ubuntu-php73-pgsql: Laravel docker image with official Ubuntu image + PHP 7.3 and PgSQL PDO
11+
### How to use this repository
4612

47-
There are 2 differente docker-compose.yml:
13+
#### Build the images (optional)
4814

49-
* docker-compose.yml-dev: Test environment
50-
* docker-compose.yml-prod: Production environment
15+
In the directory [build-env-files](build-env-files/) you will find the build environment variables for:
5116

52-
Other configurations files:
17+
* php-fpm
18+
* alpine
19+
* ubuntu
5320

54-
* .env files contain variables used by docker-compose.yml, adjust with your personal settings.
55-
* config directory contains nginx configurations (only for prod environment). Adjust domain with your own domain
56-
* init_letsencrypt.sh (optional): initializes a custom ssl certificate used by nginx on the very first initlialization of the prod enviroment
21+
and for each base image you can build the final image with: php 8, php 7.4 and php 7.3.
22+
On each *php version* subdir you will find two *build env files* one for MySQL and one for PgSQL
5723

58-
#### Variables
24+
To build the images from scratch you can run the following command:
5925

60-
Environment variables:
26+
```console
27+
docker-compose --env-file build-env-files/php-fpm/8/.env-pgsql -f build-phpfpm.yml build # --pull <- Use '--pull' if you want to update the base image
28+
```
6129

62-
* MYSQL_USER: MySQL user
63-
* MYSQL_PASSWORD: MySQL password
64-
* MYSQL_DATABASE: MySQL database
65-
* PGSQL_USER: Postgresql user
66-
* PGSQL_PASSWORD: Postgresql password
67-
* PGSQL_DB: Postgresql database
68-
* LARAVEL_DB_HOST: MySQL or Postgresql host
69-
* FORCE_MIGRATE: Tells laravel to run php artisan migrate --force at startup
70-
* FORCE_COMPOSER_UPDATE: Tells laravel to run composer update at startup
71-
* CONTAINER_ROLE: Role of the laravel container, valid values are:
72-
* queue: Run laravel as queue container. More details [here](https://laravel.com/docs/8.x/queues)
73-
* scheduler: Run laravel as scheduler container. More details [here](https://laravel.com/docs/8.x/scheduling#running-the-scheduler)
74-
* app: Run laravel to expose http applications
75-
* QUEUE_NAME: Name of the queue, required if the container is launched with CONTAINER_ROLE=queue
30+
In this case the final image will be tagged with *localbuild/laravel-docker:php80-pgsql*, you can then push the newly builded image in your registry.
7631

77-
Build arguments:
32+
The supported build variables are:
7833

79-
* DOCKER_IMAGE_VERSION: PHP base image version to use
80-
* COMPOSER_VERSION: Composer version to use
81-
* PDO: PDO to install, pdo_mysql or pdo_pgsql
82-
* DB: DB type, mysql or pgsql
83-
* PGSQL_DEP: Extra dependency fo Postgresql (optional, required for pgsql images)
34+
| Var | Desc |
35+
| `LARAVEL_VERSION` | Laravel version to be included in the builded image |
36+
| `DOCKER_IMAGE_VERSION` | PHP base image version to use |
37+
| `COMPOSER_VERSION` | Composer version to use |
38+
| `PDO` | PDO to install, pdo_mysql or pdo_pgsql |
39+
| `PGSQL_DEP` | Extra dependency fo Postgresql (optional, required for pgsql images)|
8440

85-
Build arguments used only in the "ubuntu" branch:
41+
Specific build variables needed only for Ubuntu:
8642

87-
* PHP_VERSION: Version of php to use
88-
* PHP_SHA256: SHA256 signature of the PHP package
89-
* GPG_KEYS: GPG keys of the PHP package
43+
| Var | Desc |
44+
| `PHP_VERSION` | Version of php to use |
45+
| `PHP_SHA256` | SHA256 signature of the PHP package |
46+
| `GPG_KEYS` | GPG keys of the PHP package |
9047

9148
There are a couple of "hard coded" variables inside the Dockerfile.
9249
The variables are:
@@ -96,7 +53,45 @@ The variables are:
9653

9754
Also to adjust the locale you have to modify this line "sed -i -e 's/# it_IT.UTF-8 UTF-8/it_IT.UTF-8 UTF-8/' /etc/locale.gen" with the locale you need.
9855

99-
#### Setup test or prod env
56+
#### Bring up test or prod env
57+
58+
There are 2 differente docker-compose.yml:
59+
60+
* docker-compose.yml-dev: Test environment
61+
* docker-compose.yml-prod: Production environment
62+
63+
Other configurations files:
64+
65+
* .env files contain variables used by docker-compose.yml, adjust with your personal settings.
66+
* config directory contains nginx configurations (only for prod environment). Adjust domain with your own domain
67+
* init_letsencrypt.sh (optional): initializes a custom ssl certificate used by nginx on the very first initlialization of the prod enviroment
68+
69+
### Variables
70+
71+
Laravel container accepts the following env variables:
72+
73+
| Var | Desc |
74+
| `LARAVEL_DB_HOST` | MySQL or Postgresql host |
75+
| `FORCE_MIGRATE` | Tells Laravel to run php artisan migrate --force at startup |
76+
| `FORCE_COMPOSER_UPDATE` | Tells Laravel to run composer update at startup |
77+
| `CONTAINER_ROLE` | Role of the laravel container, valid values are: queue, scheduler, app (default) |
78+
| `QUEUE_NAME` | Name of the queue, required if the container is launched with CONTAINER_ROLE=queue |
79+
80+
MySQL variables:
81+
82+
| Var | Desc |
83+
| ------- | ----------- |
84+
| `MYSQL_USER` | MySQL user |
85+
| `MYSQL_PASSWORD` | MySQL password |
86+
| `MYSQL_DATABASE` | MySQL database |
87+
88+
PgSQL variables:
89+
90+
| `PGSQL_USER` | Postgresql user |
91+
| `PGSQL_PASSWORD` | Postgresql password |
92+
| `PGSQL_DB` | Postgresql password |
93+
94+
### Setup test or prod env
10095

10196
For testing purposes copy docer-compose.yml-dev in docker-compose.yml, fire up the enviromnent with:
10297

@@ -117,30 +112,31 @@ docker-compose up -d
117112

118113
Nginx will be exposed on port 80 and 443 of your host
119114

120-
#### Queue and Scheduler containers
115+
### Queue and Scheduler containers
121116

122117
You can run the laravel container as:
123118

119+
* app. Run laravel to expose http applications (default)
124120
* queue container. More details [here](https://laravel.com/docs/8.x/queues)
125121
* scheduler container. More details [here](https://laravel.com/docs/8.x/scheduling#running-the-scheduler)
126122

127123
An example of running laravel container as queue container is:
128124

129-
```
130-
queue-default:
125+
```yaml
126+
queue_default:
131127
image: garutilorenzo/laravel:php74-pgsql
132128
build:
133129
context: laravel/
134-
container_name: queue-default
130+
container_name: queue_default
135131
volumes:
136132
- ${LARAVEL_DATA_DIR:-./laravel-project}:/var/www/html
137133
environment:
138-
- PGSQL_USER=${PGSQL_USER:-user}
139-
- PGSQL_PASSWORD=${PGSQL_PASSWORD:-password}
140-
- PGSQL_DB=${PGSQL_DB:-laravel}
141-
- LARAVEL_DB_HOST=pgsql
134+
- MYSQL_USER=${LARAVEL_DB_USER:-app}
135+
- MYSQL_PASSWORD=${LARAVEL_DB_USER:-password}
136+
- MYSQL_DATABASE=${LARAVEL_DB_NAME:-laravel}
137+
- LARAVEL_DB_HOST=${LARAVEL_DB_HOST:-mysql}
142138
- CONTAINER_ROLE=queue
143-
- QUEUE_NAME=default
139+
- QUEUE_NAME=default
144140
depends_on:
145141
- pgsql
146142
- laravel
@@ -166,7 +162,7 @@ php artisan queue:work database --queue=$QUEUE_NAME --verbose --tries=3
166162

167163
An example of running laravel container as scheduler container is:
168164

169-
```
165+
```yaml
170166
scheduler:
171167
image: garutilorenzo/laravel:php74-pgsql
172168
build:
@@ -175,10 +171,10 @@ scheduler:
175171
volumes:
176172
- ${LARAVEL_DATA_DIR:-./laravel-project}:/var/www/html
177173
environment:
178-
- PGSQL_USER=${PGSQL_USER:-user}
179-
- PGSQL_PASSWORD=${PGSQL_PASSWORD:-password}
180-
- PGSQL_DB=${PGSQL_DB:-laravel}
181-
- LARAVEL_DB_HOST=pgsql
174+
- MYSQL_USER=${LARAVEL_DB_USER:-app}
175+
- MYSQL_PASSWORD=${LARAVEL_DB_USER:-password}
176+
- MYSQL_DATABASE=${LARAVEL_DB_NAME:-laravel}
177+
- LARAVEL_DB_HOST=${LARAVEL_DB_HOST:-mysql}
182178
- CONTAINER_ROLE=scheduler
183179
depends_on:
184180
- pgsql
@@ -201,7 +197,7 @@ do
201197
done
202198
```
203199

204-
#### Enable SSL (optional)
200+
### Enable SSL (optional)
205201

206202
A configuration example is placed on config/nginx/conf.d/example.conf-ssl (rename the file with appropriate name, and delete/rename example.conf file)
207203
Remember to uncomment certbot service in docker-compose.yml-prod.
@@ -223,7 +219,7 @@ You can now start the services with:
223219
docker-compose up -d
224220
```
225221

226-
#### Notes
222+
### Notes
227223

228224
* MySQL sotre persistent data on mysql volume. The volume persist until command docker-compose down -v is gived.
229225
* Laravel docker image contains laravel v. 8.5.9. To persist your work download the laravel version you desire and extract the archive in laravel-project dir (at the same lavel on docker-compose.yml).

0 commit comments

Comments
 (0)