|
| 1 | +[](https://gitlab.com/jarnovanleeuwen/laravel-dock/pipelines) |
| 2 | + |
1 | 3 | Learning the concepts of [Docker](https://www.docker.com/), I created an example Laravel application using Docker's best architectural and security practices. The boilerplate code in this repository provides:
|
2 | 4 |
|
3 | 5 | - Best practices on security (not running as root, no passwordless databases, no unnecessary file permissions).
|
4 | 6 | - Using official Apache, PHP 7.2, MySQL 5.7 and Redis 5.0 images.
|
5 | 7 | - A single code base for **development and production environments**.
|
6 | 8 | - A single `.env` configuration file.
|
7 | 9 | - A slim `Dockerfile` using only **official images**.
|
| 10 | +- Tests structured for your CI/CD pipeline. |
8 | 11 | - A convenient binary providing `up`, `artisan`, `build`, `push`, and even `deploy` commands.
|
9 | 12 | - Deployments to a multi-server cloud environment using **Docker Swarm**.
|
10 | 13 | - Built-in support for Laravel's key concepts: **scheduling, queues, cache etc.**
|
| 14 | +- Built-in Laravel Horizon for managing queue workers through configuration. |
11 | 15 | - All configuration in source control (e.g. virtual hosts, OPcache, InnoDB parameters).
|
12 | 16 |
|
13 | 17 | # Installation
|
@@ -67,10 +71,18 @@ ufw allow 4789/udp
|
67 | 71 | ufw reload
|
68 | 72 | ```
|
69 | 73 |
|
70 |
| -# To-do |
| 74 | +# CI/CD |
| 75 | +The `sut` service in `docker-compose.test.yml` can be used for automated testing. I have experimented with automated builds and tests on [Docker Hub](https://hub.docker.com/) and [GitLab.com](https://about.gitlab.com/product/continuous-integration/)'s CI/CD pipelines. |
| 76 | + |
| 77 | +## DockerHub |
| 78 | +In the *Automated builds* configuration section, make sure to set the *Dockerfile location* to `build/Dockerfile` in your build rules. |
| 79 | + |
| 80 | +## GitLab.com |
| 81 | +The build, test and release CI/CD pipeline stages are defined in `.gitlab-ci.yml`. |
71 | 82 |
|
72 |
| -- Integrate Laravel Horizon. |
73 |
| -- Automated tests. |
74 |
| -- Automated builds. |
75 |
| -- Automated deployments. |
76 |
| -- Let's Encrypt support. |
| 83 | +## Other |
| 84 | +To 1) start the required services (i.e. MySQL), 2) wait for them to be ready, 3) run the database migrations and 4) run `phpunit`: |
| 85 | + |
| 86 | +```bash |
| 87 | +docker-compose -f build/docker-compose.test.yml run sut |
| 88 | +``` |
0 commit comments