forked from mobtitude/docker-php-xdebug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·48 lines (38 loc) · 1.4 KB
/
generate.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.4 KB
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
#!/usr/bin/env bash
#
# Generates Dockerfiles for specified PHP versions
#
# PHP Versions that will be generated
php_versions=( "8.3" "8.2" "8.1" )
# PHP variants that will be generated for each PHP version
# final source image will be generated as follow: php:7.2-cli, php:7-2-apache and php:7.2-fpm
php_docker_suffix=( "cli" "apache" "fpm" )
# Map of xdebug versions for PHP images
# PHP_VERSION => XDEBUG_VERSION
declare -A xdebug_versions
xdebug_versions=(
["8.3"]="xdebug-3.3.1"
["8.2"]="xdebug-3.3.1"
["8.1"]="xdebug-3.1.3"
)
# Changes current path to project root
script_path=$(dirname "$0")
cd "${script_path}/../" || exit 1
# Generates Dockerfiles for each PHP version and variant
for php_version in "${php_versions[@]}"; do
for php_suffix in "${php_docker_suffix[@]}"; do
target_dir="./build/${php_version}-${php_suffix}"
target_dockerfile="${target_dir}/Dockerfile"
base_image="php:${php_version}-${php_suffix}"
xdebug_version="${xdebug_versions[${php_version}]}"
xdebug_major_version=`echo "${xdebug_version}" | sed 's/xdebug-\([1-9][0-9]\{0,\}\)\..*/\1/'`
mkdir -p "${target_dir}"
cp "./src/xdebug-${xdebug_major_version}.ini" "${target_dir}/xdebug.ini"
# shellcheck disable=SC2002
cat ./src/Dockerfile \
| sed "s/#BASE_IMAGE#/${base_image}/g" \
| sed "s/#XDEBUG_VERSION#/${xdebug_version}/g" \
> "${target_dockerfile}"
echo "Generated ${target_dockerfile}"
done
done