Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c9105c

Browse files
committed
Simplifies docker-compose.yml setup, removes separate root docker-compose file, consolidates composer in php image
1 parent88346b5 commit1c9105c

7 files changed

+18
-169
lines changed

‎README.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ A pretty simplified Docker Compose workflow that sets up a LEMP network of conta
55

66
To get started, make sure you have[Docker installed](https://docs.docker.com/docker-for-mac/install/) on your system, and then clone this repository.
77

8-
Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running`docker-compose up -d --buildsite`.
8+
Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running`docker-compose up -d --buildapp`.
99

1010
After that completes, follow the steps from the[src/README.md](src/README.md) file to get your Laravel project added in (or create a new blank one).
1111

12-
Bringing up the Docker Compose network with`site` instead of just using`up`, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:
12+
Bringing up the Docker Compose network with`app` instead of just using`up`, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:
1313

1414
-**nginx** -`:80`
1515
-**mysql** -`:3306`
@@ -30,7 +30,7 @@ If you encounter any issues with filesystem permissions while visiting your appl
3030
**If you are using your server or local environment as the root user:**
3131

3232
- Bring any container(s) down with`docker-compose down`
33-
-Rename`docker-compose.root.yml` fileto`docker-compose.root.yml`, replacing the previous one
33+
-Replace any instance of`php.dockerfile` in thedocker-compose.yml filewith`php.root.dockerfile`
3434
- Re-build the containers by running`docker-compose build --no-cache`
3535

3636
**If you are using your server or local environment as a user that is not root:**
@@ -54,28 +54,12 @@ volumes:
5454
- ./mysql:/var/lib/mysql
5555
```
5656

57-
##Using BrowserSync with Laravel Mix
57+
##Usage in Production
5858

59-
If you want to enable the hot-reloading that comes with Laravel Mix's BrowserSync option, you'll have to follow a few small steps. First, ensure that you're using the updated`docker-compose.yml` with the`:3000` and`:3001` ports open on the npm service. Then, add the following to the end of your Laravel project's`webpack.mix.js` file:
60-
61-
```javascript
62-
.browserSync({
63-
proxy:'site',
64-
open:false,
65-
port:3000,
66-
});
67-
```
68-
69-
From your terminal window at the project root, run the following command to start watching for changes with the npm container and its mapped ports:
70-
71-
```bash
72-
docker-compose run --rm --service-ports npm run watch
73-
```
74-
75-
That should keep a small info pane open in your terminal (which you can exit with Ctrl + C). Visiting[localhost:3000](http://localhost:3000) in your browser should then load up your Laravel application with BrowserSync enabled and hot-reloading active.
59+
While I originally created this template for local development, it's robust enough to be used in basic Laravel application deployments. The biggest recommendation would be to ensure that HTTPS is enabled by making additions to the`nginx/default.conf` file and utilizing something like[Let's Encrypt](https://hub.docker.com/r/linuxserver/letsencrypt) to produce an SSL certificate.
7660

7761
##MailHog
7862

79-
The current version of Laravel (8 as of today) uses MailHog as the default application for testing email sending and general SMTP work during local development. Using the provided Docker Hub image, getting an instance set up and ready is simple and straight-forward. The service is included in the`docker-compose.yml` file, and spins up alongside the webserver and database services.
63+
The current version of Laravel (9 as of today) uses MailHog as the default application for testing email sending and general SMTP work during local development. Using the provided Docker Hub image, getting an instance set up and ready is simple and straight-forward. The service is included in the`docker-compose.yml` file, and spins up alongside the webserver and database services.
8064

8165
To see the dashboard and view any emails coming through the system, visit[localhost:8025](http://localhost:8025) after running`docker-compose up -d site`.

‎docker-compose.root.yml

Lines changed: 0 additions & 107 deletions
This file was deleted.

‎docker-compose.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ version: '3'
33
networks:
44
laravel:
55

6+
67
services:
7-
site:
8+
app:
89
build:
910
context:./dockerfiles
1011
dockerfile:nginx.dockerfile
1112
args:
1213
-UID=${UID:-1000}
1314
-GID=${GID:-1000}
14-
container_name:nginx
1515
ports:
1616
-80:80
1717
volumes:
@@ -26,7 +26,6 @@ services:
2626

2727
mysql:
2828
image:mariadb:10.6
29-
container_name:mysql
3029
restart:unless-stopped
3130
tty:true
3231
ports:
@@ -48,15 +47,13 @@ services:
4847
args:
4948
-UID=${UID:-1000}
5049
-GID=${GID:-1000}
51-
container_name:php
5250
volumes:
5351
-./src:/var/www/html:delegated
5452
networks:
5553
-laravel
5654

5755
redis:
5856
image:redis:alpine
59-
container_name:redis
6057
restart:unless-stopped
6158
ports:
6259
-6379:6379
@@ -66,31 +63,27 @@ services:
6663
composer:
6764
build:
6865
context:./dockerfiles
69-
dockerfile:composer.dockerfile
66+
dockerfile:php.dockerfile
7067
args:
7168
-UID=${UID:-1000}
7269
-GID=${GID:-1000}
73-
container_name:composer
7470
volumes:
7571
-./src:/var/www/html
76-
working_dir:/var/www/html
7772
depends_on:
7873
-php
79-
user:laravel
80-
entrypoint:['composer', '--ignore-platform-reqs']
74+
entrypoint:[ 'composer', '--ignore-platform-reqs' ]
8175
networks:
8276
-laravel
8377

8478
npm:
85-
image:node:13.7
86-
container_name:npm
79+
image:node:current-alpine
8780
volumes:
8881
-./src:/var/www/html
8982
ports:
9083
-3000:3000
9184
-3001:3001
9285
working_dir:/var/www/html
93-
entrypoint:['npm']
86+
entrypoint:['npm']
9487
networks:
9588
-laravel
9689

@@ -101,19 +94,16 @@ services:
10194
args:
10295
-UID=${UID:-1000}
10396
-GID=${GID:-1000}
104-
container_name:artisan
10597
volumes:
10698
-./src:/var/www/html:delegated
10799
depends_on:
108100
-mysql
109-
working_dir:/var/www/html
110-
entrypoint:['php', '/var/www/html/artisan']
101+
entrypoint:[ 'php', '/var/www/html/artisan' ]
111102
networks:
112103
-laravel
113104

114105
mailhog:
115106
image:mailhog/mailhog:latest
116-
container_name:mailhog
117107
ports:
118108
-1025:1025
119109
-8025:8025

‎dockerfiles/composer.dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎dockerfiles/nginx.root.dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎dockerfiles/php.dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN mkdir -p /var/www/html
1010

1111
WORKDIR /var/www/html
1212

13+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
14+
1315
# MacOS staff group's gid is 20, so is the dialout group in alpine linux. We're not using it, let's just remove it.
1416
RUN delgroup dialout
1517

‎dockerfiles/php.root.dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ RUN mkdir -p /var/www/html
44

55
WORKDIR /var/www/html
66

7+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
8+
79
RUN sed -i"s/user = www-data/user = root/g" /usr/local/etc/php-fpm.d/www.conf
810
RUN sed -i"s/group = www-data/group = root/g" /usr/local/etc/php-fpm.d/www.conf
911
RUN echo"php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
@@ -15,4 +17,4 @@ RUN mkdir -p /usr/src/php/ext/redis \
1517
&& echo'redis' >> /usr/src/php-available-exts \
1618
&& docker-php-ext-install redis
1719

18-
CMD ["php-fpm","-y","/usr/local/etc/php-fpm.conf","-R"]
20+
CMD ["php-fpm","-y","/usr/local/etc/php-fpm.conf","-R"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp