diff --git a/Dockerfile b/Dockerfile index b053529..384064a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,25 @@ -FROM alpine:3.14 AS builder +FROM alpine:3.15 AS builder -ENV VERSION=15.0.2 -ENV SHA256_SUM=1915e33b3789eb426fda06676e39b9ddf3a7b563e1e2381a92a02da814dad047 +ENV VERSION=17.0.0 +ENV SHA256_SUM=710851fef83c5dad4dabd1eb7e79230d68879404217342c82fc35cbecb7ba8bd RUN wget "https://github.com/keycloak/keycloak/releases/download/$VERSION/keycloak-$VERSION.tar.gz" RUN echo "$SHA256_SUM keycloak-$VERSION.tar.gz" | sha256sum -c - || exit 1 RUN mkdir -p /keycloak RUN tar xvf keycloak-$VERSION.tar.gz -C /keycloak --strip 1 -FROM thallian/confd-env:latest +FROM thallian/alpine-s6:latest RUN addgroup -g 2222 keycloak RUN adduser -h /home/keycloak -u 2222 -D -G keycloak keycloak RUN apk add --no-cache \ - openjdk11-jre-headless + openjdk17-jre-headless \ + bash COPY --from=builder --chown=keycloak:keycloak /keycloak /home/keycloak/server + +RUN /home/keycloak/server/bin/kc.sh build --db postgres RUN chown -R keycloak:keycloak /home/keycloak ADD /rootfs / diff --git a/README.md b/README.md index 85d1f31..d8f966d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ [Keycloak](https://www.keycloak.org/) server with postgre backend. # Environment Variables -## ADMIN_PASSWORD -Password for the admin user. +## HOSTNAME +Hostname to use in urls. -## DB_URL -Database url in jdbc form (https://jdbc.postgresql.org/documentation/80/connect.html). +## DB_HOST +Database host. + +## DB_NAME +- default: keycloak + +Database name. ## DB_USER - default: keycloak diff --git a/rootfs/etc/confd/conf.d/stanalone.xml.toml b/rootfs/etc/confd/conf.d/stanalone.xml.toml deleted file mode 100644 index 191cc30..0000000 --- a/rootfs/etc/confd/conf.d/stanalone.xml.toml +++ /dev/null @@ -1,6 +0,0 @@ -[template] -src = "standalone.xml.tmpl" -dest = "/home/keycloak/server/standalone/configuration/standalone.xml" -uid = 2222 -gid = 2222 -mode = "0640" diff --git a/rootfs/etc/confd/templates/standalone.xml.tmpl b/rootfs/etc/confd/templates/standalone.xml.tmpl deleted file mode 100644 index 9998068..0000000 --- a/rootfs/etc/confd/templates/standalone.xml.tmpl +++ /dev/null @@ -1,618 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - h2 - - sa - sa - - - - {{ getenv "DB_URL" }} - postgresql - - {{ getenv "DB_USER" "keycloak" }} - {{ getenv "DB_PASSWORD" }} - - - - - org.postgresql.xa.PGXADataSource - - - org.h2.jdbcx.JdbcDataSource - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - auth - - - classpath:${jboss.home.dir}/providers/* - - - master - 900 - - 2592000 - true - true - ${jboss.home.dir}/themes - - - - - - - - - - - - - jpa - - - basic - - - - - - - - - - - - - - - - - - - default - - - - - - - - ${keycloak.jta.lookup.provider:jboss} - - - - - - - - - - - ${keycloak.x509cert.lookup.provider:default} - - - - default - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rootfs/etc/cont-init.d/admin-user b/rootfs/etc/cont-init.d/admin-user deleted file mode 100644 index 8ab7fa9..0000000 --- a/rootfs/etc/cont-init.d/admin-user +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv sh - s6-setuidgid keycloak /home/keycloak/server/bin/add-user-keycloak.sh -r master -u admin -p $ADMIN_PASSWORD - diff --git a/rootfs/etc/s6-overlay/s6-rc.d/keycloak/run b/rootfs/etc/s6-overlay/s6-rc.d/keycloak/run new file mode 100644 index 0000000..db35fcd --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/keycloak/run @@ -0,0 +1,10 @@ +#!/command/with-contenv sh + +exec s6-setuidgid keycloak /home/keycloak/server/bin/kc.sh start \ + --db-url-host "$DB_HOST" \ + --db-url-database "${DB_NAME:-keycloak}" \ + --db-username "${DB_USER:-keycloak}" \ + --db-password "$DB_PASSWORD" \ + --hostname "$HOSTNAME" \ + --http-enabled true \ + --proxy edge diff --git a/rootfs/etc/s6-overlay/s6-rc.d/keycloak/type b/rootfs/etc/s6-overlay/s6-rc.d/keycloak/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/keycloak/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/keycloak b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/keycloak new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/services.d/keycloak/run b/rootfs/etc/services.d/keycloak/run deleted file mode 100644 index a2f0a5f..0000000 --- a/rootfs/etc/services.d/keycloak/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv sh - -s6-setuidgid keycloak /home/keycloak/server/bin/standalone.sh -b 0.0.0.0 diff --git a/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/module.xml b/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/module.xml deleted file mode 100644 index 8a622cd..0000000 --- a/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/module.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/postgresql-42.2.23.jar b/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/postgresql-42.2.23.jar deleted file mode 100644 index 00ad52e..0000000 Binary files a/rootfs/home/keycloak/server/modules/system/layers/keycloak/org/postgresql/main/postgresql-42.2.23.jar and /dev/null differ