Pages

Sunday, April 16, 2023

Keycloak: production ready configuration

To set up a production-ready Keycloak instance with MySQL using Docker Compose, you can follow these steps:

  1. Create a Docker Compose file named docker-compose.yml with the following contents:
version: '3.7'

services:
  keycloak:
    image: jboss/keycloak:15.0.2
    container_name: keycloak
    environment:
      - KEYCLOAK_USER=admin
      - KEYCLOAK_PASSWORD=admin
      - DB_VENDOR=mysql
      - DB_ADDR=mysql
      - DB_PORT=3306
      - DB_DATABASE=keycloak
      - DB_USER=keycloak
      - DB_PASSWORD=password
    ports:
      - "8080:8080"
    depends_on:
      - mysql

  mysql:
    image: mysql:8.0.27
    container_name: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=keycloak
      - MYSQL_USER=keycloak
      - MYSQL_PASSWORD=password
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql

volumes:
  mysql_data:


This file will create two services, one for Keycloak and one for MySQL, and link them together using the depends_on directive.

  1. Start the containers by running the following command in the same directory as your docker-compose.yml file:
docker-compose up -d

This will start the Keycloak and MySQL containers in detached mode.

  1. Wait for a few moments for the containers to start up and then access the Keycloak Admin Console by visiting http://localhost:8080/auth/admin/ in your web browser. You can log in using the credentials admin/admin.

That's it! You now have a production-ready Keycloak instance with MySQL running in Docker. Note that this is just a basic configuration, and you may need to adjust it to suit your specific needs.


    Diakin

    No comments:

    Post a Comment