dockerkeycloakwildfly

Externalize Keycloak variables from application.properties into Dockerfile


I am currently working on automating the deployment process of a Java application. The application is built and deployed into a Nexus repository using Maven (mvn deploy). Additionally, I have a Dockerfile set up to fetch either the latest or a specified WAR file version from the Nexus repository and run it on WildFly.

I am looking to improve the configuration management by externalizing the Keycloak authentication variables from application.properties. I want to include these variables directly in my Dockerfile, allowing me to change them without modifying the application.properties file every time.

How can I do this externalization in my Dockerfile, without resorting to using a docker-compose file at this stage?


Solution

  • You can define them as environment variables using ENV keyword in Dockerfile. Or using -e, --env arguments in docker run command, or if you have them in a file just use --env-file.

    You can check out some documentation:

    https://docs.docker.com/reference/cli/docker/container/run/#env

    https://www.keycloak.org/server/containers

    https://hub.docker.com/r/bitnami/keycloak