Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
chore: update tools for custom UI image (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilzi authored Feb 23, 2022
1 parent 5ec8737 commit e01ca5e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
43 changes: 35 additions & 8 deletions hacks/build_image.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
#!/usr/bin/env bash
set -e

DOCKERFILE="./Dockerfile"
REACT_APP_BUILD_MODE=""

usage() {
echo "Usage: $0 [ single-cluster ]" 1>&2
cat << EOF
This command must be executed from the root of the repository
Usage: $0 [-f <dockerfile>] [-s|--single-cluster]
EOF
}

parse_args() {
while getopts ":h" opt; do
while getopts ":f:sh" opt; do
case $opt in
h)
usage
exit 0
;;
s)
REACT_APP_BUILD_MODE="single-cluster"
;;
f)
DOCKERFILE="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Invalid option: -${opt}" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
echo "Option -$opt requires an argument." >&2
usage
exit 1
;;
*)
usage
exit 1
;;
Expand All @@ -33,12 +49,23 @@ find_tool() {
main() {
parse_args "$@"
PODMAN=$(find_tool)

pushd ../assisted-ui-lib
REACT_APP_GIT_SHA="$(git rev-parse --short HEAD)"
popd
REACT_APP_VERSION="$(git rev-parse --short HEAD)"

if [ "$DOCKERFILE" != './Dockerfile' ]; then
yarn build
fi

${PODMAN} build \
-f "$DOCKERFILE" \
--force-rm \
--tag assisted-installer-ui:"${1:-local}" \
--build-arg=REACT_APP_BUILD_MODE="$1" \
--build-arg=REACT_APP_GIT_SHA="$(git rev-parse HEAD)" \
--build-arg=REACT_APP_VERSION=latest \
--tag quay.io/"$(whoami)"/assisted-installer-ui:"$REACT_APP_GIT_SHA" \
--build-arg=REACT_APP_BUILD_MODE="$REACT_APP_BUILD_MODE" \
--build-arg=REACT_APP_GIT_SHA="$REACT_APP_GIT_SHA" \
--build-arg=REACT_APP_VERSION="$REACT_APP_VERSION" \
.
}

Expand Down
18 changes: 18 additions & 0 deletions hacks/custom.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM registry.access.redhat.com/ubi8/nginx-120 as app

# persist these on the final image for later inspection
ARG REACT_APP_BUILD_MODE
ENV BUILD_MODE=$REACT_APP_BUILD_MODE
ARG REACT_APP_GIT_SHA
ENV GIT_SHA=$REACT_APP_GIT_SHA
ARG REACT_APP_VERSION
ENV VERSION=$REACT_APP_VERSION

COPY ../deploy/deploy_config.sh /deploy/
COPY ../deploy/ui-deployment-template.yaml /deploy/
COPY ../deploy/nginx.conf /deploy/
COPY ../deploy/start.sh /deploy/

COPY --chown=1001:0 /build/ "${NGINX_APP_ROOT}/src/"

CMD [ "/deploy/start.sh" ]

0 comments on commit e01ca5e

Please sign in to comment.