-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·43 lines (34 loc) · 1.29 KB
/
build.sh
File metadata and controls
executable file
·43 lines (34 loc) · 1.29 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
#!/bin/bash
export REGISTRY_URL=${REGISTRY_URL:-}
export PROJECT_NAME=${PROJECT_NAME:-}
export TAG=${TAG:-latest}
[[ -n "$REGISTRY_URL" ]] && REGISTRY_URL="${REGISTRY_URL%/}/"
[[ -n "$PROJECT_NAME" ]] && PROJECT_NAME="${PROJECT_NAME%/}/"
REGISTRY="${REGISTRY_URL}${PROJECT_NAME}"
export REGISTRY="${REGISTRY:-}"
# Display info about the registry being used
if [ -z "$REGISTRY" ]; then
echo -e "${YELLOW}Warning: No registry prefix set. Images will be tagged without a registry prefix.${NC}"
echo "Using local image names with tag: ${TAG}"
else
echo "Using registry prefix: ${REGISTRY}"
fi
# Set the tag value
tag="${REGISTRY}nvr-event-router:${TAG}"
echo "Building $tag image..."
BUILD_ARGS=""
if [ -n "${http_proxy}" ]; then
BUILD_ARGS="${BUILD_ARGS} --build-arg http_proxy=${http_proxy}"
fi
if [ -n "${https_proxy}" ]; then
BUILD_ARGS="${BUILD_ARGS} --build-arg https_proxy=${https_proxy}"
fi
if [ -n "${no_proxy}" ]; then
BUILD_ARGS="${BUILD_ARGS} --build-arg no_proxy=${no_proxy}"
fi
# Add copyleft sources build arg if environment variable is set
if [ "$ADD_COPYLEFT_SOURCES" = "true" ]; then
BUILD_ARGS="$BUILD_ARGS --build-arg COPYLEFT_SOURCES=true"
fi
docker build ${BUILD_ARGS} -t "${tag}" -f docker/Dockerfile .
docker images | grep "$tag" && echo "Image ${tag} built successfully."