forked from telekom-mms/docker-management-container
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.sh
More file actions
30 lines (24 loc) · 666 Bytes
/
render.sh
File metadata and controls
30 lines (24 loc) · 666 Bytes
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
#!/bin/bash
# generate Dockerfile from template with build settings
# init stuff
if [ $# -ne 1 ]; then
printf "no directory provided\n\n"
echo "Usage: sh render.sh <DIRECTORY>"
exit 2
fi
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
ENV_DIR=${1-SCRIPT_DIR}
ENV_FILE="${ENV_DIR}/.docker_build"
# function
render(){
DOCKER_ARG=$(echo "${ARG}" | cut -d '=' -f1)
VERSION=$(echo "${ARG}" | cut -d '=' -f2-)
sedStr="s!ARG ${DOCKER_ARG}.*!ARG ${DOCKER_ARG}=${VERSION}!g;"
echo "${sedStr}"
}
# main
while read -r ARG
do
SED_ARG="${SED_ARG} $(render)"
done < "$ENV_FILE"
sed -r "${SED_ARG}" "${SCRIPT_DIR}/Dockerfile.template" > "${ENV_DIR}/Dockerfile"