Keycloak on Docker

keycloakのDockerfileを見てみました。
https://hub.docker.com/r/jboss/keycloak/dockerfile

最新のkeycloakはKeycloak 15.0.2なのでバージョンを修正します。
また、環境変数LANGも日本語にしましょう。

```docker:dockerfile
FROM registry.access.redhat.com/ubi8-minimal

ENV KEYCLOAK_VERSION 15.0.2
ENV JDBC_POSTGRES_VERSION 42.2.5
ENV JDBC_MYSQL_VERSION 8.0.26
ENV JDBC_MARIADB_VERSION 2.7.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 ja_JP.UTF-8

ARG GIT_REPO
ARG GIT_BRANCH
ARG KEYCLOAK_DIST=https://github.com/keycloak/keycloak/releases/download/$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"]
```
Dockerイメージを作成のコマンドは以下としました。

```
C:\kazu\keycloak>docker build -t keycloak .
[+] Building 62.8s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                             0.0s
 => => transferring dockerfile: 32B                                                              0.0s
 => [internal] load .dockerignore                                                                0.0s
 => => transferring context: 2B                                                                  0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi8-minimal:latest                  2.1s
 => [internal] load build context                                                                0.1s
 => => transferring context: 48.03kB                                                             0.0s
 => CACHED [1/4] FROM registry.access.redhat.com/ubi8-minimal@sha256:31ccb79b1b2c2d6eff1bee0db2  0.0s
 => [2/4] RUN microdnf update -y && microdnf install -y glibc-langpack-en gzip hostname java-1  22.4s
 => [3/4] ADD tools /opt/jboss/tools                                                             0.1s
 => [4/4] RUN /opt/jboss/tools/build-keycloak.sh                                                35.4s
 => exporting to image                                                                           2.7s
 => => exporting layers                                                                          2.7s
 => => writing image sha256:4a0954cca7495b00cc2f2e15bf9503977b4865a6807e3f0b07ded6a67cfe4d59     0.0s
 => => naming to docker.io/library/keycloak                                                      0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

[+] Building 68.3s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                             0.0s
 => => transferring dockerfile: 890B                                                             0.0s
 => [internal] load .dockerignore                                                                0.0s
 => => transferring context: 2B                                                                  0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi8-minimal:latest                  2.1s
 => CACHED [1/4] FROM registry.access.redhat.com/ubi8-minimal@sha256:31ccb79b1b2c2d6eff1bee0db2  0.0s
 => [internal] load build context                                                                0.0s
 => => transferring context: 3.45kB                                                              0.0s
 => [2/4] RUN microdnf update -y && microdnf install -y glibc-langpack-en gzip hostname java-1  20.2s
 => [3/4] ADD tools /opt/jboss/tools                                                             0.1s
 => [4/4] RUN /opt/jboss/tools/build-keycloak.sh                                                43.2s
 => exporting to image                                                                           2.6s
 => => exporting layers                                                                          2.6s
 => => writing image sha256:e16eacd4318af2687b29b2e68769c29411c9fee92db8380f76b9533ca1b764ac     0.0s
 => => naming to docker.io/library/keycloak                                                      0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
C:\kazu\keycloak>
```
起動は以下としました。

```
C:\kazu\keycloak>docker run -p 8080:8080 -p 8443:8443 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin --name keycloak keycloak
```
起動したらkeycloakサーバにアクセスします。httpsでアクセスしたいので、今回の作業となりました。
https://localhost:8443/auth/admin

##変更履歴
(2019/9/22)改めて、keyclockのDockerfileを見たら、「EXPOSE 8443」が追加されています。この記事も過去の歴史ですかね。また、バージョンは「7.0.0」となっています。
(2019/10/17)ベースのイメージについて追記。
(2021/08/21)最新のDockerfileに変更。keycloakは15.0.2ですね。