forked from qzeleza/kvas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.build
executable file
·47 lines (43 loc) · 1.74 KB
/
image.build
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
#! /usr/bin/env bash
. ./build/library.run
DEBUG=YES # флаг отладки процесса сборки образа
env_file=.env
#------------------------------------------------------------
user=$(get_remove_value "USER_NAME")
group=$(get_remove_value "USER_GROUP")
image_name=$(get_remove_value "IMAGE_NAME")
# ------------------------------------------------------------
# Записываем данные в файл .env для docker-compose
# ------------------------------------------------------------
cat <<EOF > "${env_file}"
APP_NAME=${APP_NAME}
APPS_ROOT=$(get_remove_value "APPS_ROOT")
APP_PATH_NAME_TO_MAKE=$(get_remove_value "APP_PATH_NAME_TO_MAKE")
IMAGE_NAME=${image_name}
CONTAINER_NAME=$(get_remove_value "CONTAINER_NAME")
USER=${user}
GROUP=${group}
UID=$(get_remove_value "U_ID")
GID=$(get_remove_value "G_ID")
DEBUG=${DEBUG}
EOF
# удаляем старые контейнеры
docker container prune -f
if [ "${1}" = build ] || [ -z "$(docker ps -a -f 'status=running' | grep "${APP_NAME}")" ]; then
# то заходим внутрь контейнера и сразу запускаем сборку пакета
# если не создан образ, то запускаем сборку образа
show_line; echo "Запускаем сборку образа ${image_name}"
show_line
docker-compose up --build -d
fi
if [ "${?}" = 0 ]; then
show_line; echo "Docker-образ собран без ошибок."
echo "Запускаем сборку пакета в самом контейнере..."
docker exec --user "${user}:${group}" -it "${image_name}" \
"/${APPS_ROOT}/${APP_NAME}/build/package.build" \
/bin/bash
else
show_line; echo "Docker-образ собран с ошибками!"
exit 1
fi
show_line