forked from serversideup/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·80 lines (64 loc) · 1.95 KB
/
dev.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
#!/bin/bash
#exit on error
set -e
##########################
# Environment Settings
DEV_UPSTREAM_CHANNEL="beta-"
# UI Colors
function ui_set_yellow {
printf $'\033[0;33m'
}
function ui_set_green {
printf $'\033[0;32m'
}
function ui_set_red {
printf $'\033[0;31m'
}
function ui_reset_colors {
printf "\e[0m"
}
# Script Configurations
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
##########################
# Set versions to build
if [ $# -eq 0 ]; then
# Set versions
phpVersions=()
echo "Running build for these PHP versions..."
# Loop through each .txt file in the current directory
for file in src/cli/php-version-packages/*.txt; do
# Trim the extension off the filename and add it to the array
phpVersion=$(basename -- "$file")
phpVersion="${phpVersion%.*}"
phpVersions+=("$phpVersion")
# Print the filename without the extension
echo "$phpVersion"
done
else
phpVersions=$1
fi
##########################
# Functions
function build (){
label=$(echo $1 | tr '[:lower:]' '[:upper:]')
ui_set_yellow && echo "⚡️ Running build for $label - ${2} ..." && ui_reset_colors
# Use "docker build"
docker build \
--build-arg UPSTREAM_CHANNEL="${DEV_UPSTREAM_CHANNEL}" \
--build-arg PHP_VERSION="${2}" \
-t "serversideup/php:beta-${2}-$1" \
$SCRIPT_DIR/src/$1/
ui_set_green && echo "✅ Build completed for $label - ${2} (serversideup/php:beta-${2}-$1)" && ui_reset_colors
}
function build_versions {
# Grab each PHP version defined in `build.sh` and deploy these images to our LOCAL registry
for version in ${phpVersions[@]}; do
build cli ${version[$i]}
build fpm ${version[$i]}
build fpm-apache ${version[$i]}
build fpm-nginx ${version[$i]}
done
}
##########################
# Main script starts here
build_versions