Containerized Keycloak in Development
How to set up an OpenID Connect compliant development environment with Docker?
If are working in a SaaS business, you are likely to have some form of identity provider (IDP). Among other things, an IDP typically takes care of authenticating users from possibly multiple tenants and keeps track of roles that may be assigned to users.
Keycloak offers an OpenID Connect (OIDC) compliant implementation of an IDP. Being available as a docker image is another plus. As I will not cover Keycloak details here, please check out their site at https://www.keycloak.org/
In this article I will demonstrate how to set up a containerized development environment with Keycloak as a dependency. Most of the content will be about Docker configuration. In a future article I will provide a running example of how to make use of this development environment.
As always, all source code for this article is available under the MIT license at: https://github.com/RimuTec/keycloak-in-local-dev-2023
The easiest path to replicating the code in this article is to install the following prerequisites:
- VS Code
- VS Code extension for remote development
- Docker Desktop
- A git client
These are the usual suspects. You should not need anything else.
Advice from practice: On my computer these four are the only development tools I have installed directly. All other tools will be defined and loaded into the development container. This is my default setup which allows me to switch between many different repositories with a wide range of technology stacks and dependencies.
The Development Container
Instead of starting from scratch, I will use a template and then modify the result to what we need here. The template can be found at https://github.com/RimuTec/dev-container-typescript . The template uses the latest TLS of Node.js, npm and TypeScript.