-
-
Save kimausloos/65702365262b47c48db15e8786c018ce to your computer and use it in GitHub Desktop.
Local php in docker
This file contains hidden or 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 characters
| #!/bin/bash | |
| READLINK="readlink" | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| hash -d greadlink | |
| if ! [ -x "$(command -v greadlink)" ]; then | |
| echo "Please make sure to install homebrew and the homebrec coreutils package" | |
| exit 1 | |
| fi | |
| READLINK="greadlink" | |
| fi | |
| DOCKER_UID=$(id -u) | |
| DOCKER_GID=$(id -g) | |
| FULL_PATH=$($READLINK -f $1) | |
| SCRIPT_PATH=$(dirname $FULL_PATH) | |
| TMP_PATH=$($READLINK -f ~/.cache/php-cache) | |
| if [ -z $PHP_VERSION ] | |
| then | |
| if [ -f "$PWD/.php_version" ] | |
| then | |
| source "$PWD/.php_version" | |
| else | |
| PHP_VERSION="7.2" | |
| fi | |
| fi | |
| docker run -i -t --rm --net=host --user $DOCKER_UID:$DOCKER_GID -e "COMPOSER_HOME=/php-cache/" -v "$TMP_PATH":"/php-cache" -v "$PWD":/app -v "$SCRIPT_PATH":"$SCRIPT_PATH" -w /app chialab/php:$PHP_VERSION php $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment