variable "REGISTRY" {
  default = "registry.mangopig.tech"
}

variable "TAG" {
  default = "latest"
}

target "_app" {
  context    = "."
  dockerfile = "Dockerfile"
}

target "dev" {
  inherits = ["_app"]
  target   = "development"
  tags     = ["goko/royal-pop/api:dev"]
}

target "prod" {
  inherits = ["_app"]
  target   = "runtime"
  tags     = ["goko/royal-pop/api:local-prod"]
}

target "dev-image" {
  inherits = ["_app"]
  target   = "development"
  tags     = ["${REGISTRY}/goko/royal-pop/api/dev:${TAG}"]
  output   = ["type=registry"]
}

target "prod-image" {
  inherits = ["_app"]
  target   = "runtime"
  tags     = ["${REGISTRY}/goko/royal-pop/api/prod:${TAG}"]
  output   = ["type=registry"]
}

group "local" {
  targets = ["dev", "prod"]
}

group "registry" {
  targets = ["dev-image", "prod-image"]
}

group "default" {
  targets = ["dev"]
}
