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

Commit926cdaa

Browse files
authored
Merge pull requestaschmelyun#122 from aschmelyun/permissions-fix-round-2
Permissions fix, round 2
2 parents2009f39 +3280904 commit926cdaa

12 files changed

+202
-59
lines changed

‎.env.example

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

‎README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ Three additional containers are included that handle Composer, NPM, and Artisan
2727

2828
##Permissions Issues
2929

30-
If you encounter any issues with filesystem permissions while visiting your application or running a container command, try completing the following steps:
30+
If you encounter any issues with filesystem permissions while visiting your application or running a container command, try completing one of the sets of steps below.
31+
32+
**If you are using your server or local environment as the root user:**
33+
34+
- Bring any container(s) down with`docker-compose down`
35+
- Rename`docker-compose.root.yml` file to`docker-compose.root.yml`, replacing the previous one
36+
- Re-build the containers by running`docker-compose build --no-cache`
37+
38+
**If you are using your server or local environment as a user that is not root:**
3139

3240
- Bring any container(s) down with`docker-compose down`
33-
- Copy the`.env.example` file in the root of this repo to`.env`
34-
- Modify the values in the`.env` file to match the user/group that the`src` directory is owned by on the host system
41+
- In your terminal, run`export UID=$(id -u)` and then`export GID=$(id -g)`
3542
- Re-build the containers by running`docker-compose build --no-cache`
3643

3744
Then, either bring back up your container network or re-run the command you were trying before, and see if that fixes it.

‎composer.dockerfile

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

‎docker-compose.root.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
version:'3'
2+
3+
networks:
4+
laravel:
5+
6+
services:
7+
site:
8+
build:
9+
context:./dockerfiles
10+
dockerfile:nginx.root.dockerfile
11+
container_name:nginx
12+
ports:
13+
-80:80
14+
volumes:
15+
-./src:/var/www/html:delegated
16+
depends_on:
17+
-php
18+
-redis
19+
-mysql
20+
-mailhog
21+
networks:
22+
-laravel
23+
24+
mysql:
25+
image:mariadb:10.6
26+
container_name:mysql
27+
restart:unless-stopped
28+
tty:true
29+
ports:
30+
-3306:3306
31+
environment:
32+
MYSQL_DATABASE:homestead
33+
MYSQL_USER:homestead
34+
MYSQL_PASSWORD:secret
35+
MYSQL_ROOT_PASSWORD:secret
36+
SERVICE_TAGS:dev
37+
SERVICE_NAME:mysql
38+
networks:
39+
-laravel
40+
41+
php:
42+
build:
43+
context:./dockerfiles
44+
dockerfile:php.root.dockerfile
45+
container_name:php
46+
volumes:
47+
-./src:/var/www/html:delegated
48+
networks:
49+
-laravel
50+
51+
redis:
52+
image:redis:alpine
53+
container_name:redis
54+
restart:unless-stopped
55+
ports:
56+
-6379:6379
57+
networks:
58+
-laravel
59+
60+
composer:
61+
image:composer:2
62+
container_name:composer
63+
volumes:
64+
-./src:/var/www/html
65+
working_dir:/var/www/html
66+
depends_on:
67+
-php
68+
user:root
69+
entrypoint:['composer', '--ignore-platform-reqs']
70+
networks:
71+
-laravel
72+
73+
npm:
74+
image:node:13.7
75+
container_name:npm
76+
volumes:
77+
-./src:/var/www/html
78+
ports:
79+
-3000:3000
80+
-3001:3001
81+
working_dir:/var/www/html
82+
entrypoint:['npm']
83+
networks:
84+
-laravel
85+
86+
artisan:
87+
build:
88+
context:./dockerfiles
89+
dockerfile:php.root.dockerfile
90+
container_name:artisan
91+
volumes:
92+
-./src:/var/www/html:delegated
93+
depends_on:
94+
-mysql
95+
working_dir:/var/www/html
96+
entrypoint:['php', '/var/www/html/artisan']
97+
networks:
98+
-laravel
99+
100+
mailhog:
101+
image:mailhog/mailhog:latest
102+
container_name:mailhog
103+
ports:
104+
-1025:1025
105+
-8025:8025
106+
networks:
107+
-laravel

‎docker-compose.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ networks:
66
services:
77
site:
88
build:
9-
context:.
9+
context:./dockerfiles
1010
dockerfile:nginx.dockerfile
1111
args:
12-
-NGINXUSER=${NGINXUSER:-www-data}
13-
-NGINXGROUP=${NGINXGROUP:-www-data}
12+
-UID=${UID:-1000}
13+
-GID=${GID:-1000}
1414
container_name:nginx
1515
ports:
1616
-80:80
@@ -43,11 +43,11 @@ services:
4343

4444
php:
4545
build:
46-
context:.
46+
context:./dockerfiles
4747
dockerfile:php.dockerfile
4848
args:
49-
-PHPUSER=${PHPUSER:-www-data}
50-
-PHPGROUP=${PHPGROUP:-www-data}
49+
-UID=${UID:-1000}
50+
-GID=${GID:-1000}
5151
container_name:php
5252
volumes:
5353
-./src:/var/www/html:delegated
@@ -65,18 +65,18 @@ services:
6565

6666
composer:
6767
build:
68-
context:.
68+
context:./dockerfiles
6969
dockerfile:composer.dockerfile
7070
args:
71-
-PHPUSER=${PHPUSER:-www-data}
72-
-PHPGROUP=${PHPGROUP:-www-data}
71+
-UID=${UID:-1000}
72+
-GID=${GID:-1000}
7373
container_name:composer
7474
volumes:
7575
-./src:/var/www/html
7676
working_dir:/var/www/html
7777
depends_on:
7878
-php
79-
user:${PHPUSER:-www-data}
79+
user:laravel
8080
entrypoint:['composer', '--ignore-platform-reqs']
8181
networks:
8282
-laravel
@@ -96,11 +96,11 @@ services:
9696

9797
artisan:
9898
build:
99-
context:.
99+
context:./dockerfiles
100100
dockerfile:php.dockerfile
101101
args:
102-
-PHPUSER=${PHPUSER:-www-data}
103-
-PHPGROUP=${PHPGROUP:-www-data}
102+
-UID=${UID:-1000}
103+
-GID=${GID:-1000}
104104
container_name:artisan
105105
volumes:
106106
-./src:/var/www/html:delegated

‎dockerfiles/composer.dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM composer:2
2+
3+
ARG UID
4+
ARG GID
5+
6+
ENV UID=${UID}
7+
ENV GID=${GID}
8+
9+
# 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.
10+
RUN delgroup dialout
11+
12+
RUN addgroup -g ${GID} --system laravel
13+
RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel
14+
15+
WORKDIR /var/www/html

‎dockerfiles/nginx.dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM nginx:stable-alpine
2+
3+
ARG UID
4+
ARG GID
5+
6+
ENV UID=${UID}
7+
ENV GID=${GID}
8+
9+
# 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.
10+
RUN delgroup dialout
11+
12+
RUN addgroup -g ${GID} --system laravel
13+
RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel
14+
RUN sed -i"s/user nginx/user laravel/g" /etc/nginx/nginx.conf
15+
16+
ADD ./nginx/default.conf /etc/nginx/conf.d/
17+
18+
RUN mkdir -p /var/www/html

‎dockerfiles/nginx.root.dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM nginx:stable-alpine
2+
3+
RUN sed -i"s/user nginx/user root/g" /etc/nginx/nginx.conf
4+
5+
ADD ./nginx/default.conf /etc/nginx/conf.d/
6+
7+
RUN mkdir -p /var/www/html
File renamed without changes.

‎dockerfiles/php.dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM php:8-fpm-alpine
2+
3+
ARG UID
4+
ARG GID
5+
6+
ENV UID=${UID}
7+
ENV GID=${GID}
8+
9+
RUN mkdir -p /var/www/html
10+
11+
WORKDIR /var/www/html
12+
13+
# 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.
14+
RUN delgroup dialout
15+
16+
RUN addgroup -g ${GID} --system laravel
17+
RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel
18+
19+
RUN sed -i"s/user = www-data/user = laravel/g" /usr/local/etc/php-fpm.d/www.conf
20+
RUN sed -i"s/group = www-data/group = laravel/g" /usr/local/etc/php-fpm.d/www.conf
21+
RUN echo"php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
22+
23+
RUN docker-php-ext-install pdo pdo_mysql
24+
25+
RUN mkdir -p /usr/src/php/ext/redis \
26+
&& curl -L https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
27+
&& echo'redis' >> /usr/src/php-available-exts \
28+
&& docker-php-ext-install redis
29+
30+
CMD ["php-fpm","-y","/usr/local/etc/php-fpm.conf","-R"]

‎php.dockerfilerenamed to‎dockerfiles/php.root.dockerfile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
FROM php:8-fpm-alpine
22

3-
ARG PHPGROUP
4-
ARG PHPUSER
5-
6-
ENV PHPGROUP=${PHPGROUP}
7-
ENV PHPUSER=${PHPUSER}
8-
9-
RUN addgroup --system ${PHPGROUP}; exit 0
10-
RUN adduser --system -G ${PHPGROUP} -s /bin/sh -D ${PHPUSER}; exit 0
11-
123
RUN mkdir -p /var/www/html
134

145
WORKDIR /var/www/html
156

16-
RUN sed -i"s/user = www-data/user =${PHPUSER}/g" /usr/local/etc/php-fpm.d/www.conf
17-
RUN sed -i"s/group = www-data/group =${PHPGROUP}/g" /usr/local/etc/php-fpm.d/www.conf
7+
RUN sed -i"s/user = www-data/user =root/g" /usr/local/etc/php-fpm.d/www.conf
8+
RUN sed -i"s/group = www-data/group =root/g" /usr/local/etc/php-fpm.d/www.conf
189
RUN echo"php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
1910

2011
RUN docker-php-ext-install pdo pdo_mysql

‎nginx.dockerfile

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp