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
Copy file name to clipboardExpand all lines: README.md
+55-9Lines changed: 55 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ Learning the concepts of [Docker](https://www.docker.com/), I created an example
13
13
- Built-in support for Laravel's key concepts: **scheduling, queues, cache etc.**
14
14
- Built-in Laravel Horizon for managing queue workers through configuration.
15
15
- All configuration in source control (e.g. virtual hosts, OPcache, InnoDB parameters).
16
+
- Compatible with GitHub Actions & Packages, DockerHub, GitLab and other CI/CD services.
16
17
17
18
# Installation
18
19
@@ -22,6 +23,7 @@ Learning the concepts of [Docker](https://www.docker.com/), I created an example
22
23
- Clone this repository
23
24
- Copy `.env.example` to `.env` and edit the file to match your environment.
24
25
- Run `./dock up`
26
+
- Run `./dock exec composer install`
25
27
- Run `./dock artisan migrate`
26
28
- Visit http://localhost/status
27
29
@@ -51,6 +53,8 @@ By default, Apache binds to port 80 and MySQL to port 3306. This, and much more,
51
53
52
54
# Setting up a multiserver environment
53
55
56
+
### Docker Swarm
57
+
54
58
Basically, any server with [Docker Swarm](https://docs.docker.com/engine/swarm/) that can be reached over SSH can be used. To give an idea on how easy it is to setup a multiserver environment, I will include the setup steps below. The steps apply to any cloud server provider, such as DigitalOcean or AWS.
55
59
56
60
- Create an SSH accessible 'manager' server and initialise the swarm: `docker swarm init --advertise-addr={Private IP}`.
@@ -60,19 +64,61 @@ Basically, any server with [Docker Swarm](https://docs.docker.com/engine/swarm/)
60
64
- On the deployment server (or developer machine) specify `DEPLOY_SERVER`.
61
65
- 🚀 Execute a rolling deployment using `./dock deploy`.
62
66
63
-
Notes: this is a simple setup for illustration purposes. In real production environment, an odd number of 3+ manager nodes is recommended for optimal fault tolerance. The same holds for replicating the web and database servers. Moreover, the swarm can be completely isolated from the Internet by only allowing Docker Swarm traffic between nodes and restricting all other traffic. Add a load balancer setup to forward public traffic on ports 80 and 443 to the swarm. Then, only the manager node would need to open port 22 (SSH) to known deployment hosts.
67
+
Note: this is a simple setup for illustration purposes. In real production environment, an odd number of 3+ manager nodes is recommended for optimal fault tolerance. The same holds for replicating the web and database servers. Moreover, the swarm can be completely isolated from the Internet by only allowing Docker Swarm traffic between nodes and restricting all other traffic. Add a load balancer setup to forward public traffic on ports 80 and 443 to the swarm. Then, only the manager node would need to open port 22 (SSH) to known deployment hosts.
64
68
65
-
Opening the required ports on swarm nodes in UFW:
66
-
```bash
67
-
ufw allow 2377/tcp
68
-
ufw allow 7946/tcp
69
-
ufw allow 7946/udp
70
-
ufw allow 4789/udp
71
-
ufw reload
69
+
### Kubernetes
70
+
71
+
Assuming you have a Kubernetes cluster, you can deploy the Laravel application, including MySQL, Redis, Horizon and a scheduler by applying the [`kubernetes.yaml`](https://github.com/jarnovanleeuwen/laravel-dock/blob/master/build/kubernetes.yaml) config. It has only been tested with DigitalOcean's persistent volumes, but the configuration can easily be updated for other cloud providers.
72
+
73
+
First, create secrets for the Docker registry and application keys and passwords.
Finally, you can run the migrations or any other artisan command.
85
+
```sh
86
+
kubectl exec -it svc/web -- php artisan migrate
72
87
```
73
88
74
89
# 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.
90
+
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. Recently, I have also added examples for GitHub's [Actions](https://github.com/features/actions) and [Packages](https://github.com/features/packages).
91
+
92
+
## GitHub
93
+
### Actions
94
+
Use the following GitHub Actions workflow to build and test your Docker image:
95
+
96
+
```yaml
97
+
name: Build and Test
98
+
on: push
99
+
100
+
jobs:
101
+
build:
102
+
name: Build
103
+
runs-on: ubuntu-latest
104
+
steps:
105
+
- uses: actions/checkout@master
106
+
- name: Build image
107
+
run: docker build --file build/Dockerfile --target production --tag app-local .
108
+
- name: Run PHPUnit
109
+
run: docker-compose -f build/docker-compose.test.yml run sut
110
+
```
111
+
112
+
### Packages
113
+
The GitHub Package Registry can be used to store your Docker images. You should [Create a personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) and edit your `.env` file accordingly:
0 commit comments