You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
46
12
47
-
There are 2 differente docker-compose.yml:
13
+
#### Build the images (optional)
48
14
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:
51
16
52
-
Other configurations files:
17
+
* php-fpm
18
+
* alpine
19
+
* ubuntu
53
20
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
57
23
58
-
#### Variables
24
+
To build the images from scratch you can run the following command:
59
25
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
+
```
61
29
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.
76
31
77
-
Build arguments:
32
+
The supported build variables are:
78
33
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)|
84
40
85
-
Build arguments used only in the "ubuntu" branch:
41
+
Specific build variables needed only for Ubuntu:
86
42
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 |
90
47
91
48
There are a couple of "hard coded" variables inside the Dockerfile.
92
49
The variables are:
@@ -96,7 +53,45 @@ The variables are:
96
53
97
54
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.
98
55
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
100
95
101
96
For testing purposes copy docer-compose.yml-dev in docker-compose.yml, fire up the enviromnent with:
102
97
@@ -117,30 +112,31 @@ docker-compose up -d
117
112
118
113
Nginx will be exposed on port 80 and 443 of your host
119
114
120
-
####Queue and Scheduler containers
115
+
### Queue and Scheduler containers
121
116
122
117
You can run the laravel container as:
123
118
119
+
* app. Run laravel to expose http applications (default)
124
120
* queue container. More details [here](https://laravel.com/docs/8.x/queues)
125
121
* scheduler container. More details [here](https://laravel.com/docs/8.x/scheduling#running-the-scheduler)
126
122
127
123
An example of running laravel container as queue container is:
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)
207
203
Remember to uncomment certbot service in docker-compose.yml-prod.
@@ -223,7 +219,7 @@ You can now start the services with:
223
219
docker-compose up -d
224
220
```
225
221
226
-
####Notes
222
+
### Notes
227
223
228
224
* MySQL sotre persistent data on mysql volume. The volume persist until command docker-compose down -v is gived.
229
225
* 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