|
| 1 | +# Distributed under the terms of the Modified BSD License. |
| 2 | + |
| 3 | +ARG BASE_NAMESPACE |
| 4 | +ARG BASE_IMG="jdk17" |
| 5 | +FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG} |
| 6 | + |
| 7 | +LABEL maintainer="haobibo@gmail.com" |
| 8 | + |
| 9 | +COPY work /opt/utils/ |
| 10 | + |
| 11 | +RUN source /opt/utils/script-setup-keycloak.sh \ |
| 12 | + && setup_keycloak \ |
| 13 | + && echo "keycloak:x:0:root" >> /etc/group \ |
| 14 | + && echo "keycloak:x:1000:0:keycloak user:/opt/keycloak:/sbin/nologin" >> /etc/passwd \ |
| 15 | + && chown -R 1000:0 /opt/keycloak |
| 16 | + |
| 17 | +ENV KEYCLOAK_HOME /opt/keycloak |
| 18 | +ENV KC_RUN_IN_CONTAINER true |
| 19 | +ENV KC_HEALTH_ENABLED true |
| 20 | +ENV KC_METRICS_ENABLED true |
| 21 | + |
| 22 | +USER 1000 |
| 23 | +EXPOSE 8080 |
| 24 | + |
| 25 | +WORKDIR ${KEYCLOAK_HOME} |
| 26 | +ENTRYPOINT ["tini", "-g", "--"] |
| 27 | + |
| 28 | +# '-c' option make bash commands are read from string. |
| 29 | +# If there are arguments after the string, they are assigned to the positional parameters, starting with $0. |
| 30 | +# '-o pipefail' prevents errors in a pipeline from being masked. |
| 31 | +# If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline. |
| 32 | +# '--login': make bash first reads and executes commands from the file /etc/profile, if that file exists. |
| 33 | +# After that, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. |
| 34 | +SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"] |
| 35 | +CMD ["/bin/bash", "--login", "bin/kc.sh", "start-dev"] |
| 36 | + |
| 37 | +# HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "--head", "-fsSk", "https://localhost:8080/health/ready" ] |
| 38 | + |
| 39 | +# docker build -t qpod/keycloak --build-arg "BASE_NAMESPACE=qpod" . |
| 40 | +# (docker rm svc-keycloak || true) && docker run -d -p 8080:8080 --name=svc-keycloak --hostname=svc-keycloak qpod/keycloak |
| 41 | +# (docker rm svc-keycloak || true) && docker run -it -p 8080:8080 --name=svc-keycloak --hostname=svc-keycloak qpod/keycloak bin/kc.sh start-dev --verbose |
0 commit comments