Building a custom Keycloak image

I’ve tried building from local source a image based upon the directions.

Where is the correct place to run the below command from the instructions? I know it should be with a Dockerfile.
I have my own Dockerfile that pulls from the JBOSS Keycloak repo that has things added to it. But it just builds the same stuff without building my new local version.

docker build --build-arg KEYCLOAK_DIST=http://localhost:8099/keycloak-10.0.2.tar.gz .

If I use the Dockerfile from the Keycloak-containers repo, I get the message below. Does anyone know a workaround? Or do I need a Redhat subscription?

Sending build context to Docker daemon  2.56 kB
Step 1/22 : FROM registry.access.redhat.com/ubi8-minimal
Trying to pull repository registry.access.redhat.com/ubi8-minimal ... 
open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory

So it seems like you need a Redhat subscription if you want that base image. I was able to build a version on CENTOS7’s docker image from docker hub. But it is big. I also probably did it outside the normal conventions for best practices. So beware and never use my trash in production The dockerfile is as follows

FROM centos:centos7
#FROM registry.access.redhat.com/ubi8-minimal

ENV KEYCLOAK_VERSION 11.0.0-SNAPSHOT
ENV JDBC_POSTGRES_VERSION 42.2.5
ENV JDBC_MYSQL_VERSION 8.0.19
ENV JDBC_MARIADB_VERSION 2.5.4
ENV JDBC_MSSQL_VERSION 7.4.1.jre11

ENV LAUNCH_JBOSS_IN_BACKGROUND 1
ENV PROXY_ADDRESS_FORWARDING false
ENV JBOSS_HOME /opt/jboss/keycloak
ENV LANG en_US.UTF-8

ARG GIT_REPO
ARG GIT_BRANCH
ARG KEYCLOAK_DIST=https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/keycloak-${KEYCLOAK_VERSION}.tar.gz

USER root

RUN yum update -y && yum install -y glibc-langpack-en gzip hostname java-11-openjdk-headless openssl tar which && yum clean all
#RUN microdnf update -y && microdnf install -y glibc-langpack-en gzip hostname java-11-openjdk-headless openssl tar which && microdnf clean all

ADD tools /opt/jboss/tools
COPY keycloak-${KEYCLOAK_VERSION}.tar.gz /opt/jboss
RUN /opt/jboss/tools/build-keycloak.sh

USER 1000

EXPOSE 8080
EXPOSE 8443

ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ]

CMD ["-b", "0.0.0.0"]

I also modfied the build-keycloak.sh script to build from a local file that is copied in. The below is the area that I modified.

else
    echo "Keycloak from [download]: $KEYCLOAK_DIST"

    cd /opt/jboss/
    tar -xzf $KEYCLOAK_DIST 
    #curl -L $KEYCLOAK_DIST | tar zx
    mv /opt/jboss/keycloak-11.0.0-SNAPSHOT /opt/jboss/keycloak
fi
ADD tools /opt/jboss/tools

where can i get tools directory, please?

You can get the code from here.