Skip to content
This repository was archived by the owner on Mar 15, 2019. It is now read-only.

Commit c540cf0

Browse files
author
Julien Neuhart
authored
v2.0.2: Mac permissions issues + README update (#42)
* fixing issues permissions on Mac: closes #41 * updating README: closes #39
1 parent 782aec7 commit c540cf0

File tree

10 files changed

+55
-33
lines changed

10 files changed

+55
-33
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h3 align="center">kickoff-docker-php</h3>
55
<p align="center">A complete stack for your PHP project powered by Docker</p>
66
<p align="center">
7-
<a href="https://github.com/thecodingmachine/kickoff-docker-php/tree/v2.0.1"><img src="https://img.shields.io/badge/stable-v2.0.1-green.svg" alt="Stable release: v2.0.1"></a>
7+
<a href="https://github.com/thecodingmachine/kickoff-docker-php/tree/v2.0.2"><img src="https://img.shields.io/badge/stable-v2.0.2-green.svg" alt="Stable release: v2.0.2"></a>
88
<a href="https://github.com/thecodingmachine/kickoff-docker-php/tree/master"><img src="https://img.shields.io/badge/unstable-master-orange.svg" alt="Unstable release: master"></a>
99
<a href="https://travis-ci.org/thecodingmachine/kickoff-docker-php"><img src="https://img.shields.io/travis/thecodingmachine/kickoff-docker-php.svg?label=Travis+CI" alt="Travis CI"></a>
1010
</p>
@@ -302,6 +302,9 @@ it will ask you the MySQL `root` password
302302
using `127.0.0.1` (or your server IP) as host and the port defined in the variable `MYSQL_HOST_PORT_TO_MAP` in your
303303
`.env` file
304304

305+
**Note:** On `production` environments, we strongly advise to not put the MySQL port on a public facing port.
306+
This should be used only in others environments.
307+
305308
#### Configuration
306309

307310
| Variable | Location | Description |
@@ -377,6 +380,9 @@ Once done, move to the `staging` environment project folder, and update the foll
377380
* If `MYSQL_ENABLE_PORTS_MAPPING=true` on both your environments, update `MYSQL_HOST_PORT_TO_MAP` in your `staging`
378381
environment to another port than the one used by your `production` environment
379382

383+
**Reminder:** On `production` environments, we strongly advise to not put the MySQL port on a public facing port.
384+
This should be used only in others environments.
385+
380386
Last but not least, start your `staging` environment by running `orbit run build up`.
381387

382388
**Note:** don't run `kickoff` command, as we only want one Traefik container!

config/.env.blueprint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ MYSQL_ROOT_PASSWORD=admin
142142
# | If true, it will map the port 3306 of the MySQL container with the host
143143
# | port defined below.
144144
# |
145+
# | On "production" environments, we strongly advise to not put the MySQL
146+
# | port on a public facing port. This should be used only in others
147+
# | environments.
148+
# |
145149

146150
MYSQL_ENABLE_PORTS_MAPPING=true
147151
MYSQL_HOST_PORT_TO_MAP=3307

config/orbit/orbit-build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ commands:
2121
run:
2222
{{ if eq "true" .EnvFiles.Config.ENABLE_DOCKER_SYNC }}
2323
- orbit generate -t docker-sync.blueprint.yml -o docker-sync.yml -v Project,config/project.yml -e Config,config/.env
24+
- orbit run script-fix-permissions-docker-sync -c config/orbit/orbit-scripts.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
2425
{{ else if eq "windows" .Os }}
2526
- cmd.exe /c echo Skipping Docker Sync configuration file generation ...
2627
{{ else }}
@@ -81,7 +82,7 @@ commands:
8182
- use: "php-fpm-build"
8283
run:
8384
- orbit generate -t modules/php-fpm/docker-compose.blueprint.yml -o modules/php-fpm/docker-compose.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
84-
- orbit run script-linux-fix-permissions-php-fpm -c config/orbit/orbit-scripts.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
85+
- orbit run script-fix-permissions-php-fpm -c config/orbit/orbit-scripts.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
8586
- orbit generate -t modules/php-fpm/conf.d/memory-limit.blueprint.ini -o modules/php-fpm/conf.d/memory-limit.ini -e Config,config/.env
8687
- orbit generate -t modules/php-fpm/php-fpm.d/memory-limit.blueprint.conf -o modules/php-fpm/php-fpm.d/memory-limit.conf -e Config,config/.env
8788
- orbit generate -t modules/php-fpm/php-fpm.d/security.blueprint.conf -o modules/php-fpm/php-fpm.d/security.conf -e Config,config/.env
@@ -98,7 +99,7 @@ commands:
9899
- use: "nginx-build"
99100
run:
100101
- orbit generate -t modules/nginx/docker-compose.blueprint.yml -o modules/nginx/docker-compose.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
101-
- orbit run script-linux-fix-permissions-nginx -c config/orbit/orbit-scripts.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
102+
- orbit run script-fix-permissions-nginx -c config/orbit/orbit-scripts.yml -v Project,config/project.yml;Modules,config/modules.yml -e Config,config/.env
102103
- docker-compose -p {{ .EnvFiles.Config.ENV }}{{ .Values.Project.name }} -f modules/nginx/docker-compose.yml build
103104

104105
# |--------------------------------------------------------------------------

config/orbit/orbit-scripts.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,51 @@
1111
commands:
1212

1313
# |--------------------------------------------------------------------------
14-
# | orbit run script-linux-fix-permissions-nginx
14+
# | orbit run script-fix-permissions-docker-sync
1515
# |--------------------------------------------------------------------------
1616
# |
17-
# | Fixes "www-data" permissions issues on Linux for NGINX.
17+
# | Fixes "www-data" permissions issues with Docker Sync.
1818
# |
1919

20-
- use: "script-linux-fix-permissions-nginx"
20+
- use: "script-fix-permissions-docker-sync"
2121
run:
22-
{{ if eq "linux" .Os }}
23-
- /bin/bash config/scripts/linux-fix-permissions.sh NGINX
22+
{{ if and (ne "windows" .Os) (eq "true" .EnvFiles.Config.ENABLE_DOCKER_SYNC) }}
23+
- /bin/bash config/scripts/fix-permissions.sh
2424
{{ else if eq "windows" .Os }}
25-
- cmd.exe /c echo Skipping for "www-data" permissions issues on Linux for NGINX container ...
25+
- cmd.exe /c echo Skipping UID binding for "www-data" user with Docker Sync ...
2626
{{ else }}
27-
- echo Skipping fix for "www-data" permissions issues on Linux for NGINX container ...
27+
- echo Skipping UID binding for "www-data" with Docker Sync ...
2828
{{ end }}
2929

3030
# |--------------------------------------------------------------------------
31-
# | orbit run script-linux-fix-permissions-php-fpm
31+
# | orbit run script-fix-permissions-nginx
3232
# |--------------------------------------------------------------------------
3333
# |
34-
# | Fixes "www-data" permissions issues on Linux for PHP-FPM.
34+
# | Fixes "www-data" permissions issues in the NGINX container.
3535
# |
3636

37-
- use: "script-linux-fix-permissions-php-fpm"
37+
- use: "script-fix-permissions-nginx"
3838
run:
39-
{{ if eq "linux" .Os }}
40-
- /bin/bash config/scripts/linux-fix-permissions.sh PHP-FPM
41-
{{ else if eq "windows" .Os }}
42-
- cmd.exe /c echo Skipping for "www-data" permissions issues on Linux for PHP-FPM container ...
43-
{{ else }}
44-
- echo Skipping fix for "www-data" permissions issues on Linux for PHP-FPM container ...
45-
{{ end }}
39+
{{ if ne "windows" .Os }}
40+
- /bin/bash config/scripts/fix-permissions.sh NGINX
41+
{{ else }}
42+
- cmd.exe /c echo Skipping UID binding for "www-data" user in the NGINX container ...
43+
{{ end }}
44+
45+
# |--------------------------------------------------------------------------
46+
# | orbit run script-fix-permissions-php-fpm
47+
# |--------------------------------------------------------------------------
48+
# |
49+
# | Fixes "www-data" permissions issues in the PHP-FPM container.
50+
# |
51+
52+
- use: "script-fix-permissions-php-fpm"
53+
run:
54+
{{ if ne "windows" .Os }}
55+
- /bin/bash config/scripts/fix-permissions.sh PHP-FPM
56+
{{ else }}
57+
- cmd.exe /c echo Skipping UID binding for "www-data" user in the PHP-FPM container ...
58+
{{ end }}
4659

4760
# |--------------------------------------------------------------------------
4861
# | orbit run script-traefik-self-signed-certificate

config/scripts/linux-fix-permissions.sh renamed to config/scripts/fix-permissions.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ sedi()
88
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@";
99
}
1010

11-
# permissions issues workaround for Linux
11+
# permissions issues workaround
1212
NEW_UID=$(id -u);
13-
NEW_GID=$(id -g);
14-
echo "Setting UID ($NEW_UID) and GID ($NEW_GID) to \"www-data\" user in $1 container ...";
1513

1614
if [ "$1" == "NGINX" ]; then
15+
echo "Setting UID ($NEW_UID) to \"www-data\" user in $1 container ...";
1716
sedi "s/\${UID}/$NEW_UID/g" ${ROOT}/modules/nginx/docker-compose.yml;
18-
sedi "s/\${GID}/$NEW_GID/g" ${ROOT}/modules/nginx/docker-compose.yml;
19-
else
17+
elif [ "$1" == "PHP-FPM" ]; then
18+
echo "Setting UID ($NEW_UID) to \"www-data\" user in $1 container ...";
2019
sedi "s/\${UID}/$NEW_UID/g" ${ROOT}/modules/php-fpm/docker-compose.yml;
21-
sedi "s/\${GID}/$NEW_GID/g" ${ROOT}/modules/php-fpm/docker-compose.yml;
20+
else
21+
echo "Setting UID ($NEW_UID) to \"www-data\" user in Docker Sync configuration file ...";
22+
sedi "s/\${UID}/$NEW_UID/g" ${ROOT}/docker-sync.yml;
2223
fi;
2324

2425
exit 0;

docker-sync.blueprint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ options:
66
syncs:
77
{{ .EnvFiles.Config.ENV }}{{ .Values.Project.name }}_sync_app:
88
src: './app/'
9+
sync_userid: ${UID}
910
sync_strategy: {{ if eq "darwin" .Os }}'native_osx'{{ else }}'unison'{{ end }}
1011
sync_excludes: ['.idea']

modules/nginx/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ FROM nginx:1.12-alpine
1010

1111
# 82 is the standard uid/gid for "www-data" in Alpine
1212
ARG UID=82
13-
ARG GID=82
1413

15-
RUN addgroup -g $GID -S www-data &&\
14+
RUN addgroup -g 82 -S www-data &&\
1615
adduser -u $UID -D -S -G www-data www-data &&\
1716
rm /etc/nginx/conf.d/default.conf

modules/nginx/docker-compose.blueprint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ services:
88
build:
99
context: .
1010
args:
11-
- UID={{ if eq "linux" .Os }}${UID}{{ else }}82{{ end }}
12-
- GID={{ if eq "linux" .Os }}${GID}{{ else }}82{{ end }}
11+
- UID={{ if ne "windows" .Os }}${UID}{{ else }}82{{ end }}
1312
container_name: {{ .EnvFiles.Config.ENV }}-{{ .Values.Project.name }}-nginx
1413
restart: {{ if and (ne "local" .EnvFiles.Config.ENV) (eq false .Values.Modules.graylog.enable) }}unless-stopped{{ else }}"no"{{ end }}
1514
labels:

modules/php-fpm/docker-compose.blueprint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ services:
1212
networks:
1313
- backend
1414
environment:
15-
- UID={{ if eq "linux" .Os }}${UID}{{ else }}82{{ end }}
16-
- GID={{ if eq "linux" .Os }}${GID}{{ else }}82{{ end }}
15+
- UID={{ if ne "windows" .Os }}${UID}{{ else }}82{{ end }}
1716
labels:
1817
- traefik.enable=false
1918
volumes:

modules/php-fpm/docker-entrypoint.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/sh
22

33
usermod -u $UID www-data;
4-
groupmod -u $GID www-data;
54
chown -R www-data:www-data /var/www/html;
65

76
exec php-fpm;

0 commit comments

Comments
 (0)