forked from eclipse-sw360/sw360
-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker_build.sh
executable file
·91 lines (75 loc) · 2.74 KB
/
docker_build.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
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# -----------------------------------------------------------------------------
# Copyright BMW CarIT GmbH 2021
# Copyright Helio Chissini de Castro 2022-2023
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# This script is executed on startup of Docker container.
# (execution of docker run cmd) starts couchdb and tomcat.
# -----------------------------------------------------------------------------
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--cvesearch-host)
shift
cvesearch_host="$1"
;;
*)
other_args+=("$1") # store other arguments
;;
esac
shift
done
# Validate the --cvesearch-host value is a URL
if [ ! -z "$cvesearch_host" ]; then
if [[ $cvesearch_host =~ ^https?:// ]]; then
sed -i "s@cvesearch.host=.*@cvesearch.host=$cvesearch_host@g"\
./backend/src/src-cvesearch/src/main/resources/cvesearch.properties
else
echo "Warning: CVE Search host is not a URL: $cvesearch_host"
fi
fi
set -- "${other_args[@]}" # restore other arguments
set -e -o pipefail
# Source the version
# shellcheck disable=SC1091
. .versions
DOCKER_IMAGE_ROOT="${DOCKER_IMAGE_ROOT:-ghcr.io/eclipse-sw360}"
SECRETS=${SECRETS:-"$PWD/scripts/docker-config/default_secrets"}
SW360_VERSION=${SW360_VERSION:-18-development}
export DOCKER_PLATFORM DOCKER_IMAGE_ROOT GIT_REVISION SECRETS
# ---------------------------
# image_build function
# Usage ( position paramenters):
# image_build <target_name> <tag_name> <version> <extra_args...>
image_build() {
local target
local name
local version
target="$1"
shift
name="$1"
shift
version="$1"
shift
docker buildx build \
--target "$target" \
--tag "${DOCKER_IMAGE_ROOT}/$name:$version" \
--tag "${DOCKER_IMAGE_ROOT}/$name:latest" \
--load \
"$@" .
}
image_build base sw360/base "$SW360_VERSION" --build-arg LIFERAY_VERSION="$LIFERAY_VERSION" --build-arg LIFERAY_SOURCE="$LIFERAY_SOURCE" "$@"
image_build thrift sw360/thrift "$THRIFT_VERSION" --build-arg THRIFT_VERSION="$THRIFT_VERSION" "$@"
image_build sw360test sw360/test "$SW360_VERSION" "$@"
image_build binaries sw360/binaries "$SW360_VERSION" --build-arg MAVEN_VERSION="$MAVEN_VERSION" \
--secret id=sw360,src="$SECRETS" \
--build-context "thrift=docker-image://${DOCKER_IMAGE_ROOT}/sw360/thrift:latest" "$@"
image_build sw360 sw360 "$SW360_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/sw360/base:latest" \
--build-context "binaries=docker-image://${DOCKER_IMAGE_ROOT}/sw360/binaries:latest" "$@"