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/
Source dockerize-clis.sh
in a shell startup script (.bashrc
, .bash_profile
or .bash_functions
):
source ~/dockerize-clis/dockerize-clis.sh
Versions and other options are configured through environment variables.
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
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)