Last active
March 16, 2022 23:11
-
-
Save chrodriguez/9ff6f4f1a0c0bc73b36c3f3835d541af to your computer and use it in GitHub Desktop.
PHP wrappers docker based
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 characters
#!/bin/bash | |
set -e | |
[ -z "$PHP_CLI_DOCKER_IMAGE" ] && ( echo You must set PHP_CLI_DOCKER_IMAGE environment variable ; exit 1) | |
PHP_OPTIONS=${PHP_OPTIONS:- -d 'date.timezone=America/Argentina/Buenos_Aires' -d memory_limit=512M} | |
PHP_CLI_DOCKER_RUN_OPTIONS=${PHP_CLI_DOCKER_RUN_OPTIONS:-'--add-host local.docker:172.17.0.1'} | |
docker run --rm -it -u `id -u $USER`:`id -g $USER` -v "`pwd`:`pwd`" -w "`pwd`" $PHP_CLI_DOCKER_RUN_OPTIONS $PHP_CLI_DOCKER_IMAGE $PHP_OPTIONS $@ |
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 characters
#!/bin/bash | |
set -e | |
PHP_SERVER_PORT=$1 | |
[ -z "$PHP_SERVER_PORT" ] && ( echo You must specify wich port to use as parameter; exit 1) | |
#if $1 was set, the remove it | |
shift | |
[ "$PHP_SERVER_PORT" -lt 1024 ] && (echo port must be greater than 1024; exit 1) | |
PHP_SERVER_DOCKER_IMAGE=${PHP_SERVER_DOCKER_IMAGE:-cespi/php-5.3:modules-apache-latest} | |
PHP_SERVER_DOCKER_RUN_OPTIONS=${PHP_SERVER_DOCKER_RUN_OPTIONS:-'--add-host local.docker:172.17.0.1'} | |
docker run --rm -it -p ${PHP_SERVER_PORT}:80 -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v "`pwd`:`pwd`" -e "APACHE_DOCUMENT_ROOT=`pwd`" -w "`pwd`" $PHP_SERVER_DOCKER_RUN_OPTIONS $PHP_SERVER_DOCKER_IMAGE $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment