diff --git a/images/showroom-content/Dockerfile b/images/showroom-content/Dockerfile index 9186a3e..7468a51 100644 --- a/images/showroom-content/Dockerfile +++ b/images/showroom-content/Dockerfile @@ -1,38 +1,39 @@ # Use Red Hat UBI9 as the base image # No AuthN necessary to this docker registry -FROM registry.access.redhat.com/ubi9 +FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/nodejs-20:latest -# Copy the entrypoint script into the container -COPY ./entrypoint.sh /entrypoint.sh +USER root # Install necessary tools -RUN dnf install --quiet -y \ +RUN dnf -y update && dnf -y upgrade && \ + dnf -y --quiet install \ git \ nodejs \ wget && \ - dnf clean all + dnf clean all && \ + rm -rf /var/cache/yum /root/.cache RUN wget -q https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \ -O /usr/bin/yq && chmod +x /usr/bin/yq - -RUN npm install --quiet -g gulp @antora/cli @antora/site-generator +RUN npm install -g gulp @antora/cli @antora/site-generator # Create a user named 'antora' -# RUN useradd -ms /bin/bash antora -RUN useradd -u 1001 -ms /bin/bash antora && \ +RUN useradd -ms /bin/bash antora && \ mkdir -p /antora && \ chown -R antora:antora /antora +# Copy the entrypoint script into the container +COPY ./entrypoint.sh /entrypoint.sh -# Make the entrypoint script executable -RUN chmod +x /entrypoint.sh - -# Change ownership of the entrypoint script to the antora user -RUN chown antora:antora /entrypoint.sh +# Make the entrypoint script executable and change ownership +RUN chmod +x /entrypoint.sh && \ + chown antora:antora /entrypoint.sh # Switch to the 'antora' user USER antora + EXPOSE 80 + # Set the entrypoint script as the command to run when the container starts ENTRYPOINT ["/entrypoint.sh"] diff --git a/images/showroom-content/Makefile b/images/showroom-content/Makefile index 531053b..1b691bd 100644 --- a/images/showroom-content/Makefile +++ b/images/showroom-content/Makefile @@ -1,14 +1,12 @@ -IMAGE_NAME = showroom-builder +IMAGE_NAME = showroom-builder +REGISTRY = docker.io/tonykay +CONTAINER_RUNTIME = podman +ARCH = x86_64 - -REGISTRY = docker.io/tonykay -CONTAINER_RUNTIME = podman -ARCH = x86_64 - -CONTAINER_HOSTNAME = antora -# RHEL_VERSION = 8.5 -# SSH_PORT = 2222 -# SHELL_COMMAND = sudo su - devops +CONTAINER_HOSTNAME = antora +# RHEL_VERSION = 8.5 +# SSH_PORT = 2222 +# SHELL_COMMAND = sudo su - devops # Used instead of docker run.... bash @@ -16,12 +14,12 @@ CONTAINER_HOSTNAME = antora : ## help: ## Show this help - technically unnecessary as `make` alone will do - @egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + @egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' build-x86 : ## Do a docker based build build-x86 : ## EXTRA_ARGS='--squash --no-cache' for example - docker build \ - -f Containerfile \ + docker build \ + -f Containerfile \ --platform linux/amd64 \ --tag $(REGISTRY)/$(IMAGE_NAME):$${VERSION:-latest} \ --load \ @@ -29,10 +27,7 @@ build-x86 : ## EXTRA_ARGS='--squash --no-cache' for example build-multi : ## Do a docker based build build-multi : ## EXTRA_ARGS='--squash --no-cache' for example - docker buildx build \ + docker buildx build \ --platform linux/arm64/v8,linux/amd64 \ --tag $(REGISTRY)/$(IMAGE_NAME):$${VERSION:-latest} \ $(EXTRA_ARGS) . - - - # --push \ diff --git a/images/showroom-content/entrypoint.sh b/images/showroom-content/entrypoint.sh index 581bbaf..2dd70c4 100755 --- a/images/showroom-content/entrypoint.sh +++ b/images/showroom-content/entrypoint.sh @@ -1,29 +1,35 @@ #!/bin/bash -if [ -z "$GIT_REPO_URL" ]; then +if [ -z "${GIT_REPO_URL}" ]; then echo "GIT_REPO_URL is not set. Exiting." exit 1 fi -if [ -z "$ANTORA_PLAYBOOK" ]; then +if [ -z "${ANTORA_PLAYBOOK}" ]; then echo "ANTORA_PLAYBOOK not defined. Falling back to ANTORA_PLAYBOOK=default-site.yml" ANTORA_PLAYBOOK="default-site.yml" fi - WORKDIR=/showroom/repo/ -test -d $WORKDIR && rm -rfv ${WORKDIR} +test -d ${WORKDIR} && rm -rfv ${WORKDIR} echo -echo "git clone the $GIT_REPO_URL into $WORKDIR" -git clone $GIT_REPO_URL $WORKDIR -cd $WORKDIR +echo "git clone the ${GIT_REPO_URL} into ${WORKDIR}" +git clone ${GIT_REPO_URL} ${WORKDIR} +cd ${WORKDIR} + +if [ -z ${GIT_REPO_REF} ]; then + echo "No GIT_REPO_REF specified. Using default branch" +else + echo "Checking out ref ${GIT_REPO_REF}" + git checkout ${GIT_REPO_REF} +fi echo echo "Original user_data in content/antora.yml" -cat $WORKDIR/content/antora.yml +cat ${WORKDIR}/content/antora.yml -if [ -z "$USER_DATA_FILE" ]; then +if [ -z "${USER_DATA_FILE}" ]; then echo echo "USER_DATA_FILE not defined. Falling back to USER_DATA_FILE=/user_data/user_data.yml" USER_DATA_FILE="/user_data/user_data.yml" @@ -33,18 +39,18 @@ if test -r ${USER_DATA_FILE} then echo echo "Merging ${USER_DATA_FILE} and antora.yml"} - yq -i ".asciidoc.attributes *= load(\"${USER_DATA_FILE}\")" $WORKDIR/content/antora.yml + yq -i ".asciidoc.attributes *= load(\"${USER_DATA_FILE}\")" ${WORKDIR}/content/antora.yml echo "new user_data in content/antora.yml" else echo echo "USER_DATA_FILE: ${USER_DATA_FILE} not found." exit 1 fi -cat $WORKDIR/content/antora.yml +cat ${WORKDIR}/content/antora.yml echo WWW_ROOT=/showroom/www/ -test -d $WWW_ROOT || mkdir $WWW_ROOT +test -d ${WWW_ROOT} || mkdir ${WWW_ROOT} echo echo "Antora version" @@ -52,15 +58,13 @@ antora --version # Run antora command (adjust the playbook file as needed) echo -echo "Run antora $ANTORA_PLAYBOOK" - - +echo "Run antora ${ANTORA_PLAYBOOK}" -antora --to-dir=$WWW_ROOT $ANTORA_PLAYBOOK +antora --to-dir=${WWW_ROOT} ${ANTORA_PLAYBOOK} echo echo "Run httpd" -cd $WWW_ROOT +cd ${WWW_ROOT} python3 -m http.server # Additional commands or logic can be added here if needed