-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.sh
executable file
·61 lines (51 loc) · 2.33 KB
/
test.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
#!/bin/bash
# Script to build and tests Dolibarr Docker images.
#
# Usage:
# sudo test.sh develop
# sudo test.sh 18.0.5 php8.1
#
set -e
BASE_DIR="$( cd "$(dirname "$0")" && pwd )"
DOLI_VER=${1}
PHP_VER=${2:-""}
if [ "${DOLI_VER}" = "" ]; then
echo "Usage: sudo test.sh develop"
echo " sudo test.sh 18.0.5 8.1"
exit
fi
rm -rf "${BASE_DIR}/docker-compose-links/" && mkdir "${BASE_DIR}/docker-compose-links"
# shellcheck disable=SC2044
for directory in $(find "${BASE_DIR}/images" -maxdepth 1 -mindepth 1 -type d -printf '%f\n'); do
dolibarrVersion=$(echo "${directory}" | cut -d\- -f1)
phpVersion=$(echo "${directory}" | cut -d\- -f2)
#dolibarrMajor=$(echo "${dolibarrVersion}" | cut -d. -f1)
phpMajor=$(echo "${phpVersion}" | cut -d. -f1)
ln -nfs "${BASE_DIR}/images/${directory}" "${BASE_DIR}/docker-compose-links/${directory}"
if [ "${phpMajor}" = "php7" ]; then
ln -nfs "${BASE_DIR}/images/${directory}" "${BASE_DIR}/docker-compose-links/${dolibarrVersion}"
fi
done
if which docker-compose > /dev/null; then
dockerComposeBin="docker-compose"
else
dockerComposeBin="docker compose"
fi
echo "Testing for:"
echo " - Dolibarr ${DOLI_VER}"
if [ "${PHP_VER}" = "" ]; then
echo " - PHP most recent"
echo "Building image ..."
echo "DOLI_VERSION=${DOLI_VER} PHP_VERSION='' $dockerComposeBin -f '${BASE_DIR}/docker-compose.yml' [down|...]"
DOLI_VERSION=${DOLI_VER} PHP_VERSION="" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" down 1>/dev/null
DOLI_VERSION=${DOLI_VER} PHP_VERSION="" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" build web
DOLI_VERSION=${DOLI_VER} PHP_VERSION="" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" up --force-recreate web cron
DOLI_VERSION=${DOLI_VER} PHP_VERSION="" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" down
else
echo " - PHP ${PHP_VER}"
echo "Building image ..."
DOLI_VERSION=${DOLI_VER} PHP_VERSION="-php${PHP_VER}" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" down 1>/dev/null
DOLI_VERSION=${DOLI_VER} PHP_VERSION="-php${PHP_VER}" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" build web
DOLI_VERSION=${DOLI_VER} PHP_VERSION="-php${PHP_VER}" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" up --force-recreate web cron
DOLI_VERSION=${DOLI_VER} PHP_VERSION="-php${PHP_VER}" $dockerComposeBin -f "${BASE_DIR}/docker-compose.yml" down
fi