@@ -4,6 +4,12 @@ resource "random_string" "storage_suffix" {
44 upper = false
55}
66
7+ resource "random_password" "mariadb_password" {
8+ length = 16
9+ special = true
10+ override_special = " !#$%&*()-_=+[]{}<>:?"
11+ }
12+
713resource "azurerm_virtual_network" "minio_vnet" {
814 name = " minio-vnet"
915 address_space = [" 10.10.0.0/16" ]
@@ -71,8 +77,8 @@ resource "azurerm_storage_share" "minio_share" {
7177 quota = var. storage_share_size
7278}
7379
74- resource "azurerm_storage_share" "postgres_share " {
75- name = " postgresstorageshare "
80+ resource "azurerm_storage_share" "mariadb_share " {
81+ name = " mariadbstorageshare "
7682 storage_account_id = azurerm_storage_account. minio_storage_account . id
7783 quota = 10
7884}
@@ -465,35 +471,40 @@ resource "azurerm_container_group" "minio_aci_container_group" {
465471 }
466472
467473 container {
468- name = " postgres "
469- image = " postgres:16-alpine "
474+ name = " mariadb "
475+ image = " mariadb:11 "
470476 cpu = " 0.5"
471477 memory = " 1.0"
472478 cpu_limit = 1.0
473479 memory_limit = 1.5
474480
475481 environment_variables = {
476- POSTGRES_DB = var.postgres_db
477- POSTGRES_USER = var.postgres_user
478- POSTGRES_PASSWORD = var.postgres_password
482+ MARIADB_USER = var.mariadb_user
483+ MARIADB_PASSWORD = random_password.mariadb_password.result
484+ MARIADB_DATABASE = var.mariadb_database
485+ MARIADB_ROOT_PASSWORD = random_password.mariadb_password.result
479486 }
480487
481488 ports {
482- port = 5432
489+ port = 3306
483490 protocol = " TCP"
484491 }
485492
486493 volume {
487- name = " postgres -data"
488- mount_path = " /var/lib/postgresql/data "
494+ name = " mariadb -data"
495+ mount_path = " /var/lib/mysql "
489496 read_only = false
490497 storage_account_name = azurerm_storage_account. minio_storage_account . name
491498 storage_account_key = azurerm_storage_account. minio_storage_account . primary_access_key
492- share_name = azurerm_storage_share. postgres_share . name
499+ share_name = azurerm_storage_share. mariadb_share . name
500+ }
501+
502+ security {
503+ privilege_enabled = true
493504 }
494505
495506 liveness_probe {
496- exec = [" pg_isready " , " -U " , var . postgres_user , " -d " , var . postgres_db ]
507+ exec = [" /bin/sh " , " -c " , " mariadb -u root -p$MARIADB_ROOT_PASSWORD -e 'SELECT 1' " ]
497508
498509 initial_delay_seconds = 30
499510 period_seconds = 10
@@ -517,14 +528,16 @@ resource "azurerm_container_group" "minio_aci_container_group" {
517528 KC_HOSTNAME_STRICT = " false"
518529 KC_PROXY_HEADERS = " xforwarded"
519530 KEYCLOAK_IMPORT = " /opt/keycloak/data/import/realm-config.json"
520- KC_DB = " postgres"
521- KC_DB_URL = " jdbc:postgresql://localhost/${ var . postgres_db } "
522- KC_DB_USERNAME = var.postgres_user
523- KC_DB_PASSWORD = var.postgres_password
531+ KC_DB = " mariadb"
532+ KC_DB_URL = " jdbc:mariadb://localhost:3306/${ var . mariadb_database } "
533+ KC_DB_USERNAME = var.mariadb_user
534+ KC_DB_PASSWORD = random_password.mariadb_password.result
535+ KC_HTTP_PORT = " 8083"
536+ KC_HOSTNAME = " localhost"
524537 }
525538
526539 ports {
527- port = 8080
540+ port = 8083
528541 protocol = " TCP"
529542 }
530543
@@ -540,22 +553,26 @@ resource "azurerm_container_group" "minio_aci_container_group" {
540553
541554 volume {
542555 name = " keycloak-data"
543- mount_path = " /opt/keycloak/data/h2 "
556+ mount_path = " /opt/keycloak/data"
544557 read_only = false
545558 storage_account_name = azurerm_storage_account. minio_storage_account . name
546559 storage_account_key = azurerm_storage_account. minio_storage_account . primary_access_key
547560 share_name = azurerm_storage_share. keycloak_share . name
548561 }
549562
550- commands = [" start" , " --import-realm" ]
563+ commands = [
564+ " /bin/bash" ,
565+ " -c" ,
566+ " until timeout 1 bash -c 'cat < /dev/null > /dev/tcp/localhost/3306' 2>/dev/null; do echo 'Waiting for MariaDB...'; sleep 2; done && /opt/keycloak/bin/kc.sh start --import-realm"
567+ ]
551568
552569 liveness_probe {
553570 http_get {
554571 path = " /health/live"
555- port = 8080
572+ port = 8083
556573 scheme = " http"
557574 }
558- initial_delay_seconds = 120
575+ initial_delay_seconds = 400
559576 period_seconds = 30
560577 timeout_seconds = 10
561578 failure_threshold = 3
@@ -564,10 +581,10 @@ resource "azurerm_container_group" "minio_aci_container_group" {
564581 readiness_probe {
565582 http_get {
566583 path = " /health/ready"
567- port = 8080
584+ port = 8083
568585 scheme = " http"
569586 }
570- initial_delay_seconds = 60
587+ initial_delay_seconds = 400
571588 period_seconds = 10
572589 timeout_seconds = 5
573590 failure_threshold = 3
@@ -593,7 +610,7 @@ resource "azurerm_container_group" "minio_aci_container_group" {
593610 MINIO_ROOT_USER = var.minio_root_user
594611 MINIO_ROOT_PASSWORD = var.minio_root_password
595612 MINIO_BROWSER_REDIRECT_URL = " https://${ azurerm_public_ip . agw_pip . fqdn } "
596- MINIO_IDENTITY_OPENID_CONFIG_URL = " http://localhost:8082 /realms/minio_realm/.well-known/openid-configuration"
613+ MINIO_IDENTITY_OPENID_CONFIG_URL = " http://localhost:8083 /realms/minio_realm/.well-known/openid-configuration"
597614 MINIO_IDENTITY_OPENID_CLIENT_ID = " minio-client"
598615 MINIO_IDENTITY_OPENID_CLIENT_SECRET = var.keycloak_client_secret
599616 MINIO_IDENTITY_OPENID_CLAIM_NAME = " policy"
@@ -631,7 +648,7 @@ resource "azurerm_container_group" "minio_aci_container_group" {
631648 name = " coraza-waf"
632649 image = var. coraza_waf_image
633650 cpu = " 1.0"
634- memory = " 1 .0"
651+ memory = " 2 .0"
635652 cpu_limit = 1.0
636653 memory_limit = 2.0
637654 ports {
@@ -667,16 +684,16 @@ resource "azurerm_container_group" "minio_aci_container_group" {
667684 }
668685 # The Caddyfile is included as part of the container build.
669686 # If you are testing or want to use a different configuration, you can provide your own
670- # volume {
671- # name = "caddyfile"
672- # mount_path = "/etc/caddy"
673- # read_only = true
674-
675- # secret = {
676- # "Caddyfile" = base64encode(templatefile("${path.module}/Caddyfile.working.tpl ", {
677- # }))
678- # }
679- # }
687+ volume {
688+ name = " caddyfile"
689+ mount_path = " /etc/caddy"
690+ read_only = true
691+
692+ secret = {
693+ " Caddyfile" = base64encode (templatefile (" ${ path . module } /Caddyfile.azure " , {
694+ }))
695+ }
696+ }
680697
681698 }
682699}
0 commit comments