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

Commit3bb548f

Browse files
committed
Attempts to fix permissions issues
Instead of trying to replicate the host machine's user and group, a laravel user and group is created with the same uid/gid of the host machine
1 parent2009f39 commit3bb548f

File tree

4 files changed

+41
-33
lines changed

4 files changed

+41
-33
lines changed

‎composer.dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
FROM composer:2
22

3-
ARG PHPGROUP
4-
ARG PHPUSER
3+
ENV UID=1000
4+
ENV GID=1000
55

6-
ENV PHPGROUP=${PHPGROUP}
7-
ENV PHPUSER=${PHPUSER}
6+
ARG UID=${UID}
7+
ARG GID=${GID}
88

9-
RUN addgroup --system ${PHPGROUP}; exit 0
10-
RUN adduser --system -G ${PHPGROUP} -s /bin/sh -D ${PHPUSER}; exit 0
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
1114

1215
WORKDIR /var/www/html

‎docker-compose.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
context:.
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
@@ -46,8 +46,8 @@ services:
4646
context:.
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
@@ -68,15 +68,15 @@ services:
6868
context:.
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
@@ -99,8 +99,8 @@ services:
9999
context:.
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

‎nginx.dockerfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
FROM nginx:stable-alpine
22

3-
ARG NGINXGROUP
4-
ARG NGINXUSER
3+
ENV UID=1000
4+
ENV GID=1000
55

6-
ENV NGINXGROUP=${NGINXGROUP}
7-
ENV NGINXUSER=${NGINXUSER}
6+
ARG UID=${UID}
7+
ARG GID=${GID}
88

9-
RUN sed -i"s/user www-data/user ${NGINXUSER}/g" /etc/nginx/nginx.conf
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
1011

11-
ADD ./nginx/default.conf /etc/nginx/conf.d/
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
1215

13-
RUN mkdir -p /var/www/html
16+
ADD ./nginx/default.conf /etc/nginx/conf.d/
1417

15-
RUN addgroup --system ${NGINXGROUP}; exit 0
16-
RUN adduser --system -G ${NGINXGROUP} -s /bin/sh -D ${NGINXUSER}; exit 0
18+
RUN mkdir -p /var/www/html

‎php.dockerfile

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

3-
ARG PHPGROUP
4-
ARG PHPUSER
3+
ENV UID=1000
4+
ENV GID=1000
55

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
6+
ARG UID=${UID}
7+
ARG GID=${GID}
118

129
RUN mkdir -p /var/www/html
1310

1411
WORKDIR /var/www/html
1512

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
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
1821
RUN echo"php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
1922

2023
RUN docker-php-ext-install pdo pdo_mysql

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp