Shell functions to run PHP or Node related commands on Docker
| dockerize-clis-ansible.sh | ||
| dockerize-clis-node.sh | ||
| dockerize-clis-php.sh | ||
| dockerize-clis-shell.sh | ||
| dockerize-clis.sh | ||
| README.md | ||
Dockerize-CLIs
Shell functions to run PHP or Node related commands on Docker.
This project allows the dockerization of common commands :
php, composer, phpunit, node, npm and yarn.
Some Windows quirks and workarounds are handled (winpty usage for TTY problems, MSYS Posix path conversion)
Inspired by:
- https://gist.github.com/flyingluscas/a2fc4e637f3d967d427105055f6be8cd
- https://hub.docker.com/r/library/composer/
Installation
Source dockerize-clis.sh in a shell startup script (.bashrc, .bash_profile or .bash_functions):
source ~/dockerize-clis/dockerize-clis.sh
Configuration
Versions and other options are configured through environment variables.
Enable dockerized commands
By default, no function is enabled. Set the corresponding variables to enable or configure the dockerized commands.
DOCKERIZE_PHP=true
DOCKERIZE_COMPOSER=true
DOCKERIZE_PHPUNIT=true
source ~/dockerize-clis/dockerize-clis.sh
Configuration variables reference
Here are all the used variables, with their default value and suggestions.
DOCKERIZE_PHP=false
DOCKERIZE_COMPOSER=false
DOCKERIZE_PHPUNIT=false
DOCKERIZE_PHPSTAN=false
DOCKERIZE_NODE=false
DOCKERIZE_NPM=false
DOCKERIZE_YARN=false
DOCKERIZE_SHELLCHECK=true
PHP_VERSION=8.1
PHP_PUBLISH_PORTS="" # ex: "--publish 8000:8000"
PHP_USER=$(id -u):$(id -g) # or: www-data
NODE_VERSION=19
NODE_PUBLISH_PORTS="" # ex: "--publish 3000:3000"
NODE_USER=$(id -u):$(id -g) # or: node
NODE_USER_HOME=/home/node
SHELLCHECK_VERSION=stable
DOCKER_COMMON_VOLUMES="" # ex: "--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro"
# (non-existant user workaround, for Unices)