forked from tuxgasy/docker-dolibarr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·93 lines (74 loc) · 2.81 KB
/
update.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
#!/bin/bash
set -e
DOCKER_BUILD=${DOCKER_BUILD:-0}
DOCKER_PUSH=${DOCKER_PUSH:-0}
BASE_DIR="$( cd "$(dirname "$0")" && pwd )"
source "${BASE_DIR}/versions.sh"
tags=""
rm -rf "${BASE_DIR}/images" "${BASE_DIR}/docker-compose-links"
if [ "${DOCKER_BUILD}" = "1" ] && [ "${DOCKER_PUSH}" = "1" ]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --driver docker-container --use
docker buildx inspect --bootstrap
fi
for dolibarrVersion in "${DOLIBARR_VERSIONS[@]}"; do
echo "Generate Dockerfile for Dolibarr ${dolibarrVersion}"
tags="${tags}\n\*"
dolibarrMajor=$(echo ${dolibarrVersion} | cut -d. -f1)
# Mapping version according https://wiki.dolibarr.org/index.php/Versions
# Regarding PHP Supported version : https://www.php.net/supported-versions.php
if [ "${dolibarrVersion}" = "develop" ] || [ "${dolibarrMajor}" -ge "19" ]; then
php_base_images=( "8.2-apache-buster" )
elif [ "${dolibarrMajor}" -ge "16" ]; then
php_base_images=( "8.1-apache-buster" )
else
php_base_images=( "7.4-apache-buster" )
fi
for php_base_image in "${php_base_images[@]}"; do
php_version=$(echo "${php_base_image}" | cut -d\- -f1)
if [ "${dolibarrVersion}" = "develop" ]; then
currentTag="${dolibarrVersion}"
else
currentTag="${dolibarrVersion}-php${php_version}"
tags="${tags} ${currentTag}"
fi
buildOptionTags="--tag tuxgasy/dolibarr:${currentTag}"
if [ "${dolibarrVersion}" != "develop" ]; then
buildOptionTags="${buildOptionTags} --tag tuxgasy/dolibarr:${dolibarrVersion} --tag tuxgasy/dolibarr:${dolibarrMajor}"
fi
if [ "${dolibarrVersion}" = "${DOLIBARR_LATEST_TAG}" ]; then
buildOptionTags="${buildOptionTags} --tag tuxgasy/dolibarr:latest"
fi
dir="${BASE_DIR}/images/${currentTag}"
mkdir -p "${dir}"
sed 's/%PHP_BASE_IMAGE%/'"${php_base_image}"'/;' "${BASE_DIR}/Dockerfile.template" | \
sed 's/%DOLI_VERSION%/'"${dolibarrVersion}"'/;' \
> "${dir}/Dockerfile"
cp -a "${BASE_DIR}/docker-init.php" "${dir}/docker-init.php"
cp -a "${BASE_DIR}/docker-run.sh" "${dir}/docker-run.sh"
if [ "${DOCKER_BUILD}" = "1" ]; then
if [ "${DOCKER_PUSH}" = "1" ]; then
docker buildx build \
--push \
--compress \
--platform linux/arm/v7,linux/arm64,linux/amd64 \
${buildOptionTags} \
"${dir}"
else
docker build \
--compress \
${buildOptionTags} \
"${dir}"
fi
fi
done
if [ "${dolibarrVersion}" = "develop" ]; then
tags="${tags} develop"
else
tags="${tags} ${dolibarrVersion} ${dolibarrMajor}"
fi
if [ "${dolibarrVersion}" = "${DOLIBARR_LATEST_TAG}" ]; then
tags="${tags} latest"
fi
done
sed 's/%TAGS%/'"${tags}"'/' "${BASE_DIR}/README.template" > "${BASE_DIR}/README.md"