This repository was archived by the owner on Sep 23, 2023. It is now read-only.
forked from serversideup/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·88 lines (66 loc) · 2.88 KB
/
dev.sh
File metadata and controls
executable file
·88 lines (66 loc) · 2.88 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
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
#!/bin/bash
##########################
# Bash settings
# #exit on error
set -e
# perform cleanup on error
trap 'catch' EXIT
##########################
# Variables and font colors
# Set to match our local development docker registry
DEVELOPMENT_REPO_URL="localhost:5000"
##########################
# Execute other build script
# Run a build and include all variables
source ./build.sh
##########################
# Functions
function cleanup {
# Set all files back to original repo name
find $SCRIPT_DIR/$OUTPUT_DIR/ -name 'Dockerfile' -exec sed -i.bak "s/FROM $DEVELOPMENT_REPO_URL\/php/FROM serversideup\/php/" {} \;
remove_backup_files
}
function catch {
if [ "$?" != "0" ]; then
ui_set_red && echo "❌ An error has occurred, see above. Cleaning things up..." && ui_reset_colors
# error handling goes here
cleanup
fi
}
function set_local_registry {
# Unfortunately I have to use a workaround here to make it Linux & macOS friendly (https://stackoverflow.com/a/44864004)
# Temporarily set images to our local registry.
find $SCRIPT_DIR/$OUTPUT_DIR/ -name 'Dockerfile' -exec sed -i.bak "s/FROM serversideup\/php/FROM $DEVELOPMENT_REPO_URL\/php/" {} \;
remove_backup_files
}
function remove_backup_files {
# Remove our temporary backup files (related to https://stackoverflow.com/a/44864004)
find $SCRIPT_DIR/$OUTPUT_DIR -name '*.bak' -exec rm {} \;
}
function build {
# Grab each PHP version defined in `build.sh` and deploy these images to our LOCAL registry
for version in ${phpVersions[@]}; do
##############
# CLI
ui_set_yellow && echo "⚡️ Running build for CLI - ${version[$i]} ..." && ui_reset_colors
docker build -t "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-cli" $OUTPUT_DIR/${version[$i]}/cli/
docker push "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-cli"
# FPM
ui_set_yellow && echo "⚡️ Running build for FPM - ${version[$i]} ..." && ui_reset_colors
docker build -t "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm" $OUTPUT_DIR/${version[$i]}/fpm/
docker push "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm"
# FPM-APACHE
ui_set_yellow && echo "⚡️ Running build for FPM-APACHE - ${version[$i]} ..." && ui_reset_colors
docker build -t "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm-apache" $OUTPUT_DIR/${version[$i]}/fpm-apache/
docker push "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm-apache"
# FPM-NGINX
ui_set_yellow && echo "⚡️ Running build for FPM-NGINX - ${version[$i]} ..." && ui_reset_colors
docker build -t "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm-nginx" $OUTPUT_DIR/${version[$i]}/fpm-nginx/
docker push "${DEVELOPMENT_REPO_URL}/php:${version[$i]}-fpm-nginx"
done
}
##########################
# Main script starts here
set_local_registry
build
cleanup