-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerize-clis.sh
109 lines (88 loc) · 3.36 KB
/
dockerize-clis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
################################################################################
# Dockerized CLIs
#
# Inspired by:
# https://gist.github.com/flyingluscas/a2fc4e637f3d967d427105055f6be8cd
#
################################################################################
# Windows quirks & workarounds
# Windows TTY problems workaround
if [ "$OSTYPE" == "msys" ] || [ "$OSTYPE" == "cygwin" ]; then
function docker {
(winpty docker "$@")
}
fi
function dockerize_path {
local path=$1
# Prefix with "/" to avoid MSYS Posix path conversion
# @see
# http://www.mingw.org/wiki/Posix_path_conversion
# https://github.com/moby/moby/issues/12590
# https://github.com/moby/moby/issues/24029
# https://github.com/rprichard/winpty/issues/88
# https://github.com/rprichard/winpty/issues/127
[ "$OSTYPE" == "msys" ] && path="/${path}"
echo $path
}
function dockerize_bind_path {
local path=$1
# Add "/host_mnt" prefix for Docker
# @see
# https://docs.docker.com/v17.12/docker-for-windows/release-notes/docker-community-edition-17120-ce-win47-2018-01-12
# https://github.com/docker/for-win/issues/1509#issuecomment-356419753
[ "$OSTYPE" == "msys" ] && path="/host_mnt${path}"
echo $(dockerize_path $path)
}
################################################################################
# Common configuration
DOCKERIZE_CLIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Volumes mounted in every container
DOCKER_COMMON_VOLUMES=${DOCKER_COMMON_VOLUMES:-""}
################################################################################
# Load scripts
# Shell-related commands
source $DOCKERIZE_CLIS_DIR/dockerize-clis-shell.sh
# PHP-related commands
source $DOCKERIZE_CLIS_DIR/dockerize-clis-node.sh
# NodeJS-related commands
source $DOCKERIZE_CLIS_DIR/dockerize-clis-php.sh
# Ansible-related commands
source $DOCKERIZE_CLIS_DIR/dockerize-clis-ansible.sh
################################################################################
# Common utilities
function docker_clis_pull {
docker pull php:$PHP_VERSION-cli
docker pull composer
docker pull phpstan/phpstan
docker pull node:$NODE_VERSION
docker pull koalaman/shellcheck:$SHELLCHECK_VERSION
docker pull ansible/ansible-runner:$ANSIBLE_VERSION
}
function docker_clis_env {
echo "DOCKERIZE_PHP : $DOCKERIZE_PHP"
echo "DOCKERIZE_COMPOSER : $DOCKERIZE_COMPOSER"
echo "DOCKERIZE_PHPUNIT : $DOCKERIZE_PHPUNIT"
echo "DOCKERIZE_PHPSTAN : $DOCKERIZE_PHPSTAN"
echo "DOCKERIZE_NODE : $DOCKERIZE_NODE"
echo "DOCKERIZE_NPM : $DOCKERIZE_NPM"
echo "DOCKERIZE_YARN : $DOCKERIZE_YARN"
echo "DOCKERIZE_SHELLCHECK : $DOCKERIZE_SHELLCHECK"
echo "DOCKERIZE_ANSIBLE : $DOCKERIZE_ANSIBLE"
echo ""
echo "PHP_VERSION : $PHP_VERSION"
echo "PHP_PUBLISH_PORTS : $PHP_PUBLISH_PORTS"
echo "PHP_USER : $PHP_USER"
echo ""
echo "COMPOSER_HOME : $COMPOSER_HOME"
echo ""
echo "NODE_VERSION : $NODE_VERSION"
echo "NODE_PUBLISH_PORTS : $NODE_PUBLISH_PORTS"
echo "NODE_USER : $NODE_USER"
echo "NODE_USER_HOME : $NODE_USER_HOME"
echo ""
echo "SHELLCHECK_VERSION: $SHELLCHECK_VERSION"
echo ""
echo "ANSIBLE_VERSION : $ANSIBLE_VERSION"
echo ""
echo "DOCKER_COMMON_VOLUMES : $DOCKER_COMMON_VOLUMES"
}