Skip to content

Commit

Permalink
Fix antora content image to use nodejs 20 UBI and observe git ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Kulhanek authored and Wolfgang Kulhanek committed Dec 14, 2023
1 parent 6f1564f commit f8c30ac
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
29 changes: 15 additions & 14 deletions images/showroom-content/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
29 changes: 12 additions & 17 deletions images/showroom-content/Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
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

: ## TIP! make supports tab completion with *modern* shells e.g. zsh etc
: ##

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 \
$(EXTRA_ARGS) .

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 \
38 changes: 21 additions & 17 deletions images/showroom-content/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -33,34 +39,32 @@ 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"
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

0 comments on commit f8c30ac

Please sign in to comment.