version: '3'
services:
php:
volumes:
- "./web:/var/www/html"
version: '3'
services:
web:
image: nginx:alpine
volumes:
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
- "./etc/ssl:/etc/ssl"
- "./web:/var/www/html"
- "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
- "/etc/passwd:/etc/passwd"
- "/etc/groups:/etc/groups"
ports:
- "80:80"
- "3000:443"
environment:
- NGINX_HOST=${NGINX_HOST}
command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
restart: always
user: "1001:1001"
depends_on:
- php
- mysqldb
php:
build:
context: .
dockerfile: DockerfilePhpWithGit
restart: always
user: "1001:1001"
volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./web:/var/www/html"
- "/etc/passwd:/etc/passwd"
- "/etc/groups:/etc/groups"
SRC_DIR=/path/to/mounted/volume
DIR=/path/to/dir
USER=www-data
GROU=www-data
$uid=$(stat -c '%u' $SRC_DIR)
$gid=$(stat -c '%g' $SRC_DIR)
echo $uid > /root/uid
echo $gid > /root/gid
usermod -u $uid $USER
groupmod -g $gid $GROUP
mkdir -p $DIR
chown -R $USER:$GROUP $DIR