Last active
April 6, 2023 08:38
Revisions
-
dkarlovi revised this gist
Feb 2, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,8 @@ LOGS_DIR=${VAR_DIR}/logs # this sets up proper masking and (default and current) permissions for var/cache, var/logs # any user can create / edit / delete new and existing files regardless who the owner is # note: you do NOT need to run chmod 777 on these folders or "sudo" anything (hello, Ubuntu users!) # for this to work properly permissions: setfacl -dRm m:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm m:rwX ${CACHE_DIR} ${LOGS_DIR} -
dkarlovi revised this gist
Feb 2, 2018 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,7 @@ LOGS_DIR=${VAR_DIR}/logs # this sets up proper masking and (default and current) permissions for var/cache, var/logs # any user can create / edit / delete new and existing files regardless who the owner is # note: you do NOT need to run chmod 777 on these folders for this to work properly permissions: setfacl -dRm m:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm m:rwX ${CACHE_DIR} ${LOGS_DIR} This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # this is a wrapper which allows you to run commands WITHIN your Docker-Compose cluster # as you would with on your local machine, but with everything in the cluster available # just by prepending it with "bin/dsh" # -
dkarlovi revised this gist
Feb 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,4 @@ permissions: # you can run this directly from host as your current user has all correct privileges clean: rm -rf ${CACHE_DIR}/* ${LOGS_DIR}/* -
dkarlovi revised this gist
Feb 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,4 @@ permissions: # you can run this directly from host as your current user has all correct privileges clean: rm -rf ${CACHE_DIR}/* ${VAR_DIR}/* -
dkarlovi created this gist
Feb 2, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ FROM alpine:3.7 # this is the "app" image, contains PHP-FPM RUN addgroup -g 82 -S www-data && \ adduser -u 82 -H -D -S -G www-data www-data && \ # etc.. # PHP-FPM is setup to run as "www-data" WORKDIR /app This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # same user ID as in the Dockerfile APP_RUNNER_ID=82 VAR_DIR=var CACHE_DIR=${VAR_DIR}/cache LOGS_DIR=${VAR_DIR}/logs # this sets up proper masking and (default and current) permissions for var/cache, var/logs # any user can create / edit / delete new and existing files regardless who the owner is permissions: setfacl -dRm m:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm m:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -dRm u:`whoami`:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm u:`whoami`:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -dRm u:${APP_RUNNER_ID}:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm u:${APP_RUNNER_ID}:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -dRm u:root:rwX ${CACHE_DIR} ${LOGS_DIR} setfacl -Rm u:root:rwX ${CACHE_DIR} ${LOGS_DIR} # you can run this directly from host as your current user has all correct privileges clean: rm -rf ${CACHE_DIR}/* ${VAR_DIR}/* This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #!/bin/bash # this is a wrapper which allows you to run commands within your Docker-Compose cluster # as you would with on your local machine, but with everything in the cluster available # just by prepending it with "bin/dsh" # # for example: # bin/dsh bin/console doctrine:schema:update --force # bin/dsh bin/console cache:clear # etc. # can also be root, but almost never needed: # bin/dsh -u root bin/console must:be:root:to:run:this usage() { echo "Usage: $0 [-u <www-data|root>] [-c <app>]" 1>&2; exit; } CONTAINER="app" USER="$(id -u):$(id -g)" while getopts ":u:c:" o; do case "${o}" in c) CONTAINER="${OPTARG}" ((CONTAINER == 'app')) || usage ;; u) USER="${OPTARG}" ((USER == 'root' || USER == 'www-data')) || usage USER="${USER}:${USER}" ;; *) usage ;; esac done shift "$((OPTIND-1))" ROOT="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)"; COMMAND="${@}" if [ "${COMMAND}" == "" ]; then COMMAND="sh"; fi; docker-compose -f "${ROOT}/docker-compose.yml" exec --user="${USER}" "${CONTAINER}" ${COMMAND}