Skip to content

Instantly share code, notes, and snippets.

@carlosedp
Created October 13, 2020 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosedp/a2ecf5c860f04e48bcb2ba5f5e1cc90c to your computer and use it in GitHub Desktop.
Save carlosedp/a2ecf5c860f04e48bcb2ba5f5e1cc90c to your computer and use it in GitHub Desktop.
Dockerfiles for Keycloak and Gatekeeper
# Building on Docker buildx
# docker buildx build --platform linux/arm64,linux/amd64,linux/ppc64le -t repo/keycloak-gatekeeper:v9.0.0 . --push
# docker buildx build --platform linux/arm64,linux/amd64,linux/ppc64le --build-arg VERSION=8.0.0 -t repo/keycloak-gatekeeper:v8.0.0 . --push
# docker buildx build --platform linux/arm64,linux/amd64,linux/ppc64le --build-arg VERSION=master -t repo/keycloak-gatekeeper:latest . --push
# Build on Docker
# For the default os/arch (linux/amd64) and version (9.0.0)
# docker build -t repo/keycloak-gatekeeper:v9.0.0 .
# Builder container
FROM golang:1.14 as builder
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=9.0.0
WORKDIR $GOPATH/src/app
RUN git clone https://github.com/keycloak/keycloak-gatekeeper.git -b $VERSION --depth=1 && \
cd keycloak-gatekeeper && \
GOOS=$TARGETOS GOARCH=$TARGETARCH make && \
mv bin/keycloak-gatekeeper /keycloak-gatekeeper
# Application Container
FROM registry.access.redhat.com/ubi8-minimal
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=9.0.0
ENV NAME keycloak-gatekeeper
ENV KEYCLOAK_VERSION $VERSION
ENV GOOS $TARGETOS
ENV GOARCH $TARGETARCH
LABEL Name=keycloak-gatekeeper \
Release=https://github.com/keycloak/keycloak-gatekeeper \
Url=https://github.com/keycloak/keycloak-gatekeeper \
Help=https://issues.jboss.org/projects/KEYCLOAK
USER root
WORKDIR "/opt/gatekeeper"
RUN echo "gatekeeper:x:1000:gatekeeper" >> /etc/group
RUN echo "gatekeeper:x:1000:1000:gatekeeper user:/opt/gatekeeper:/sbin/nologin" >> /etc/passwd
RUN chown -R gatekeeper:gatekeeper /opt/gatekeeper && chmod -R g+rw /opt/gatekeeper
RUN microdnf update -y && microdnf install -y ca-certificates
COPY --from=builder /keycloak-gatekeeper /opt/gatekeeper/keycloak-gatekeeper
RUN microdnf clean all
USER 1000
ENTRYPOINT [ "/opt/gatekeeper/keycloak-gatekeeper" ]
# Building
# docker buildx build --platform linux/arm64,linux/amd64,linux/ppc64le -t repo/keycloak:v9.0.0 . --push
# docker buildx build --platform linux/arm64,linux/amd64,linux/ppc64le --build-arg VERSION=8.0.0 -t repo/keycloak:v8.0.0 . --push
FROM registry.access.redhat.com/ubi8-minimal
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=11.0.0
ENV KEYCLOAK_VERSION $VERSION
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 8.2.2.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 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
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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment