Skip to content

Commit 8652b83

Browse files
Merge pull request #528 from zhuje/build-image
NO-JIRA: Update build-image.sh
2 parents 8cb6726 + dccdb66 commit 8652b83

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ deploy-acm:
7979

8080
.PHONY: build-mcp-image
8181
build-mcp-image:
82-
DOCKER_FILE_NAME="Dockerfile.mcp" scripts/build-image.sh
82+
DOCKER_FILE_NAME="Dockerfile.mcp" REPO="monitoring-console-plugin" scripts/build-image.sh
8383

8484
.PHONY: build-dev-mcp-image
8585
build-dev-mcp-image:
86-
DOCKER_FILE_NAME="Dockerfile.dev-mcp" scripts/build-image.sh
86+
DOCKER_FILE_NAME="Dockerfile.dev-mcp" REPO="monitoring-console-plugin" scripts/build-image.sh
8787

8888
.PHONY: start-feature-console
8989
start-feature-console:

scripts/build-image.sh

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,17 @@ PUSH="${PUSH:-0}"
77
TAG="${TAG:-v1.0.0}"
88
REGISTRY_ORG="${REGISTRY_ORG:-openshift-observability-ui}"
99
DOCKER_FILE_NAME="${DOCKER_FILE_NAME:-Dockerfile.dev}"
10+
REPO="${REPO:-monitoring-plugin}"
1011

11-
# Terminal output colors
12-
YELLOW='\033[0;33m'
13-
ENDCOLOR='\033[0m' # No Color
12+
# Define ANSI color codes
1413
RED='\033[0;31m'
14+
GREEN='\033[0;32m'
15+
ENDCOLOR='\033[0m'
1516

16-
17-
# due to apple silicon limitation with installing npm packages inside amd64 images, builds of the frontend must be done outside the dockerfile.
18-
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$DOCKER_FILE_NAME" == "Dockerfile.mcp" ]]; then
19-
printf "${YELLOW}Updateing plugin-name ${ENDCOLOR}\n"
20-
make update-plugin-name
21-
export I18N_NAMESPACE='plugin__monitoring-console-plugin'
22-
23-
printf "${YELLOW}Installing Frontend${ENDCOLOR}\n"
24-
make install-frontend
25-
26-
printf "${YELLOW}Building Frontend${ENDCOLOR}\n"
27-
make build-frontend
17+
# Prompt user for TAG
18+
read -p "$(echo -e "${RED}Enter a value for TAG [${TAG}]: ${ENDCOLOR}")" USER_TAG
19+
if [ -n "$USER_TAG" ]; then
20+
TAG="$USER_TAG"
2821
fi
2922

3023
if [[ -x "$(command -v podman)" && $PREFER_PODMAN == 1 ]]; then
@@ -33,23 +26,35 @@ else
3326
OCI_BIN="docker"
3427
fi
3528

36-
BASE_IMAGE="quay.io/${REGISTRY_ORG}/monitoring-plugin"
29+
BASE_IMAGE="quay.io/${REGISTRY_ORG}/${REPO}"
3730
IMAGE=${BASE_IMAGE}:${TAG}
3831

32+
echo_vars() {
33+
echo "Environmental Variables set to : "
34+
echo -e "${GREEN} PREFER_PODMAN: ${ENDCOLOR} ${PREFER_PODMAN}"
35+
echo -e "${GREEN} PUSH: ${ENDCOLOR} ${PUSH}"
36+
echo -e "${GREEN} TAG: ${ENDCOLOR} ${TAG}"
37+
echo -e "${GREEN} REGISTRY_ORG: ${ENDCOLOR} ${REGISTRY_ORG}"
38+
echo -e "${GREEN} DOCKER_FILE_NAME: ${ENDCOLOR} ${DOCKER_FILE_NAME}"
39+
echo -e "${GREEN} REPO: ${ENDCOLOR}: ${REPO}"
40+
echo -e "${GREEN} IMAGE: ${ENDCOLOR}: ${IMAGE}"
41+
}
42+
echo_vars
43+
44+
# Prompt use it check env vars before proceeding to build
45+
read -r -p "Are the environmental variables correct [y/N] " response
46+
if [[ "${response:0:1}" =~ ^([nN])$ ]]
47+
then
48+
exit 0
49+
fi
50+
51+
# Build
52+
echo -e "${GREEN} Linting... ${ENDCOLOR}"
3953
make lint-backend
4054

41-
echo "Building image '${IMAGE}' with ${OCI_BIN}"
55+
echo -e "${GREEN} Building image '${IMAGE}' with ${OCI_BIN} ${ENDCOLOR}"
4256
$OCI_BIN build -t $IMAGE --platform=linux/amd64 -f $DOCKER_FILE_NAME .
4357

44-
if [[ $PUSH == 1 ]]; then
58+
if [[ $PUSH == 1 ]]; then
4559
$OCI_BIN push $IMAGE
4660
fi
47-
48-
49-
# Rollback local changes made
50-
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$DOCKER_FILE_NAME" == "Dockerfile.mcp" ]]; then
51-
printf "${YELLOW}Replacing in package.json and values.yaml${ENDCOLOR}\n"
52-
sed -i 's/"name": "monitoring-console-plugin",/"name": "monitoring-plugin",/g' web/package.json
53-
printf "${YELLOW}Renaming translations to the original plugin name${ENDCOLOR}\n"
54-
cd web/locales/ && for dir in *; do if cd $dir; then for filename in *; do mv plugin__monitoring-console-plugin.json plugin__monitoring-plugin.json; done; cd ..; fi; done
55-
fi

0 commit comments

Comments
 (0)