resource "scaleway_container_namespace" "miniauth" {
  name        = "miniauth"
  description = "Miniauth for gutes team"
  project_id  = "d7b7ab2d-478c-44af-9f66-f90af976a779"
}


resource "scaleway_container" "main" {
  name           = "miniauth-webgui"
  description    = "The webpage for the user authentification"
  namespace_id   = scaleway_container_namespace.miniauth.id
  registry_image = "git.keks.cloud/kekskurse/miniauth:latest"
  port           = 8080
  cpu_limit      = 100
  memory_limit   = 128
  min_scale      = 0
  max_scale      = 1
  timeout        = 600
  privacy        = "public"
  protocol       = "http1"
  deploy         = true
  http_option    = "redirected"

  environment_variables = {
    "WEB_PUBLIC_REGISTRATION" = "1"
    "SMTP_SERVER"             = "smtp.tem.scw.cloud"
    "SMTP_FROM"               = "auth@gutes.team"
  }
  secret_environment_variables = {
    "USERSTORE_SQLITE_PATH" = "USERSTORE_SQLITE_PATH_SED"
    "SMTP_USERNAME"         = "SMTP_USERNAME_SED"
    "SMTP_PASSWORD"         = "SMTP_PASSWORD_SED"
  }
}