apache / airavata-custos

Apache Airavata Custos Security
https://airavata.apache.org/custos
Apache License 2.0
15 stars 27 forks source link

Keycloak images fail to run on Apple Silicon (m1) #381

Closed machristie closed 1 year ago

machristie commented 1 year ago

For the version of Keycloak images that Custos uses, there are no native arm images. I ran into the following error when Keycloak image runs in the x86 emulator:

containers-keycloak-1      | 20:25:27,304 ERROR [org.jgroups.protocols.UDP] (ServerService Thread Pool -- 60) failed setting interface to /172.20.0.3: java.net.SocketException: Protocol not available (Error setting socket option)
containers-keycloak-1      | 20:25:27,306 ERROR [org.jgroups.protocols.UDP] (ServerService Thread Pool -- 60) failed setting interface to /172.20.0.3: java.net.SocketException: Protocol not available (Error setting socket option)
containers-keycloak-1      | 20:25:27,309 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 60) MSC000001: Failed to start service org.wildfly.clustering.jgroups.channel.ee: org.jboss.msc.service.StartException in service org.wildfly.clustering.jgroups.channel.ee: java.lang.IllegalStateException: java.net.SocketException: Protocol not available

Turns out this is a known issue. I found this helpful comment: https://github.com/docker/for-mac/issues/5310#issuecomment-877653653

I adapted this into a little shell script to build local, native Keycloak images

#/bin/bash

# based on https://github.com/docker/for-mac/issues/5310#issuecomment-877653653

# VERSION=14.0.0 # set version here
VERSION=9.0.2 # set version here

TEMP_DIR=$( mktemp -d )
cd $TEMP_DIR
git clone https://github.com/keycloak/keycloak-containers
cd keycloak-containers/server
git checkout $VERSION
docker build -t "jboss/keycloak:${VERSION}" .
docker build -t "quay.io/keycloak/keycloak:${VERSION}" .

I'm just creating this issue to document the workaround I found.