# Docker Bake configuration for RxMinder # Provides advanced multi-platform build configuration variable "DOCKER_REGISTRY" { default = "" } variable "DOCKER_TAG" { default = "latest" } variable "APP_NAME" { default = "RxMinder" } variable "NODE_ENV" { default = "production" } # Get git information for tagging function "git_hash" { params = [] result = notequal("", GIT_COMMIT) ? substr(GIT_COMMIT, 0, 7) : "unknown" } function "git_branch" { params = [] result = notequal("", GIT_BRANCH) ? replace(GIT_BRANCH, "/", "-") : "unknown" } # Main target group group "default" { targets = ["app"] } # Production target group group "production" { targets = ["app-prod"] } # Development target group group "development" { targets = ["app-dev"] } # All targets group group "all" { targets = ["app", "app-dev", "app-prod"] } # Base application target target "app" { dockerfile = "docker/Dockerfile" contexts = { src = "." } platforms = [ "linux/amd64", "linux/arm64" ] args = { APP_NAME = APP_NAME NODE_ENV = NODE_ENV VITE_COUCHDB_URL = "http://couchdb:5984" VITE_COUCHDB_USER = "admin" VITE_COUCHDB_PASSWORD = "change-this-secure-password" APP_BASE_URL = "http://localhost:8080" VITE_GOOGLE_CLIENT_ID = "" VITE_GITHUB_CLIENT_ID = "" MAILGUN_API_KEY = "" MAILGUN_DOMAIN = "" MAILGUN_FROM_EMAIL = "" } tags = [ notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:${DOCKER_TAG}" : "rxminder:${DOCKER_TAG}", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:latest" : "rxminder:latest", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:${git_hash()}" : "rxminder:${git_hash()}" ] labels = { "org.opencontainers.image.title" = "RxMinder" "org.opencontainers.image.description" = "Medication reminder application" "org.opencontainers.image.version" = DOCKER_TAG "org.opencontainers.image.revision" = git_hash() "org.opencontainers.image.source" = "https://github.com/username/rxminder" "org.opencontainers.image.created" = timestamp() "org.opencontainers.image.licenses" = "MIT" } cache-from = [ "type=gha" ] cache-to = [ "type=gha,mode=max" ] } # Production-specific target target "app-prod" { inherits = ["app"] args = { APP_NAME = APP_NAME NODE_ENV = "production" VITE_COUCHDB_URL = "https://your-production-couchdb.com" VITE_COUCHDB_USER = "admin" VITE_COUCHDB_PASSWORD = "secure-production-password" APP_BASE_URL = "https://your-domain.com" VITE_GOOGLE_CLIENT_ID = "" VITE_GITHUB_CLIENT_ID = "" MAILGUN_API_KEY = "" MAILGUN_DOMAIN = "" MAILGUN_FROM_EMAIL = "" } tags = [ notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:prod-${DOCKER_TAG}" : "rxminder:prod-${DOCKER_TAG}", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:prod-latest" : "rxminder:prod-latest", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:prod-${git_hash()}" : "rxminder:prod-${git_hash()}" ] labels = { "org.opencontainers.image.title" = "RxMinder Production" "org.opencontainers.image.description" = "Medication reminder application - Production build" "org.opencontainers.image.version" = DOCKER_TAG "org.opencontainers.image.revision" = git_hash() "org.opencontainers.image.source" = "https://github.com/username/rxminder" "org.opencontainers.image.created" = timestamp() "org.opencontainers.image.licenses" = "MIT" "build.environment" = "production" } } # Development-specific target target "app-dev" { inherits = ["app"] args = { APP_NAME = APP_NAME NODE_ENV = "development" VITE_COUCHDB_URL = "http://localhost:5984" VITE_COUCHDB_USER = "admin" VITE_COUCHDB_PASSWORD = "change-this-secure-password" APP_BASE_URL = "http://localhost:8080" VITE_GOOGLE_CLIENT_ID = "" VITE_GITHUB_CLIENT_ID = "" MAILGUN_API_KEY = "" MAILGUN_DOMAIN = "" MAILGUN_FROM_EMAIL = "" } tags = [ notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:dev-${DOCKER_TAG}" : "rxminder:dev-${DOCKER_TAG}", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:dev-latest" : "rxminder:dev-latest", notequal("", DOCKER_REGISTRY) ? "${DOCKER_REGISTRY}/rxminder:dev-${git_hash()}" : "rxminder:dev-${git_hash()}" ] labels = { "org.opencontainers.image.title" = "RxMinder Development" "org.opencontainers.image.description" = "Medication reminder application - Development build" "org.opencontainers.image.version" = DOCKER_TAG "org.opencontainers.image.revision" = git_hash() "org.opencontainers.image.source" = "https://github.com/username/rxminder" "org.opencontainers.image.created" = timestamp() "org.opencontainers.image.licenses" = "MIT" "build.environment" = "development" } } # Local development target (single platform) target "app-local" { inherits = ["app-dev"] platforms = ["linux/amd64"] tags = [ "rxminder:local", "rxminder:dev-local" ] output = ["type=docker"] } # Testing target target "app-test" { inherits = ["app"] args = { APP_NAME = "RxMinder-Test" NODE_ENV = "test" VITE_COUCHDB_URL = "http://localhost:5984" VITE_COUCHDB_USER = "admin" VITE_COUCHDB_PASSWORD = "test-password" APP_BASE_URL = "http://localhost:8080" } tags = [ "rxminder:test", "rxminder:test-${git_hash()}" ] labels = { "org.opencontainers.image.title" = "RxMinder Test" "org.opencontainers.image.description" = "Medication reminder application - Test build" "build.environment" = "test" } output = ["type=docker"] }