Docker Build Workflow (build.docker.yaml)
The Docker Build Workflow is the primary container image builder for all DashClicks microservices. It uses a matrix strategy to build and push Docker images for 12 different services in parallel, with support for both manual triggers and workflow calls from other automation processes.
🏗️ Overview
- File:
.github/workflows/build.docker.yaml - Purpose: Build and push Docker images for all microservices
- Trigger: Manual dispatch and workflow calls
- Services: 12 microservices across the DashClicks platform
- Registry: Google Cloud Registry (GCR)
- Concurrency: Parallel builds with concurrency control
🔧 Workflow Configuration
Trigger Events
on:
workflow_dispatch:
inputs:
env:
description: 'Image Environment'
required: true
tag:
description: 'Image Tag'
required: true
workflow_call:
inputs:
env:
description: 'Image Environment'
required: true
type: string
tag:
description: 'Image Tag'
required: true
type: string
Concurrency Control
concurrency:
group: docker-build-${{ inputs.tag }}
cancel-in-progress: true
Prevents duplicate builds for the same tag, canceling in-progress builds when new ones start.
🏢 Service Matrix
The workflow builds images for 12 distinct services using a matrix strategy:
Core API Services
| Service Name | Context | Build Script | Dockerfile |
|---|---|---|---|
api-internal | ./internal | cp -r shared/* internal/api/v1 | Dockerfile |
api-external | ./external | cp -r shared/* external/Integrations | Dockerfile |
api-ai | ./ai-service | (none) | Dockerfile |
Gateway & Communication
| Service Name | Context | Build Script | Dockerfile |
|---|---|---|---|
dashboard-gateway | ./dashboard-gateway | cp -r shared/* dashboard-gateway | Dockerfile |
socket-conversation | ./conversation-socket | cp -r shared/* conversation-socket && node common/index | Dockerfile |
socket-general | ./general-socket | cp -r shared/* general-socket | Dockerfile |
Background Processing
| Service Name | Context | Build Script | Dockerfile |
|---|---|---|---|
queue-manager-general | ./queue-manager | cp -r shared/* queue-manager | Dockerfile.general |
queue-manager-puppeteer | ./queue-manager | cp -r shared/* queue-manager | Dockerfile.puppeteer |
notifications | ./notifications | (none) | Dockerfile |
Utility Services
| Service Name | Context | Build Script | Dockerfile |
|---|---|---|---|
callrail-proxy | ./misc/callrail-recordings | (none) | Dockerfile |
currency-converter | ./misc/currency | (none) | Dockerfile |
misc-proxy | ./misc/proxy-server | (none) | Dockerfile |
🔄 Build Process
Job Flow
- Set Sandbox ID: Display the build tag for identification
- Matrix Build: Execute parallel builds for all 12 services
- Shared File Distribution: Copy shared models and utilities to service directories
- Docker Build & Push: Build images and push to Google Cloud Registry
Build Script Execution
Each service may require shared file distribution before building:
# Node.js services with shared dependencies
cp -r shared/* internal/api/v1
cp -r shared/* external/Integrations
cp -r shared/* dashboard-gateway
cp -r shared/* conversation-socket && node common/index
cp -r shared/* general-socket
cp -r shared/* queue-manager
# Services without build scripts (standalone)
# - api-ai (Deno-based)
# - notifications (with npmrc)
# - callrail-proxy
# - currency-converter
# - misc-proxy
🐳 Docker Image Management
Image Naming Convention
gcr.io/dash-208313/dashclicks-[ENVIRONMENT]-[SERVICE]:[TAG]
Examples:
gcr.io/dash-208313/dashclicks-production-api-internal:v1.2.3gcr.io/dash-208313/dashclicks-staging-socket-conversation:feature-123gcr.io/dash-208313/dashclicks-development-queue-manager-general:sandbox-456
Tagging Strategy
- Commit Tag: Git SHA for image identification
- Sandbox Tag: Custom tag for environment deployment
- Environment Tag: Environment-specific image versions
🔧 Special Configurations
NPM Registry Authentication
The notifications service requires GitHub Packages authentication:
- name: notifications
context: './notifications'
build_script: ''
dockerfile: 'Dockerfile'
with_npmrc: 'true'
This creates a .npmrc file with GitHub Packages registry configuration:
@dashclicks-llc:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=[PACKAGE_TOKEN]
Deno Service Handling
The api-ai service uses Deno instead of Node.js:
- No shared file copying required
- Native Deno Docker build process
- TypeScript-first build environment
🔐 Security & Authentication
Required Secrets
GKE_SA_KEY: Google Cloud service account key
GKE_PROJECT: Google Cloud project ID
PACKAGE_TOKEN: GitHub Packages authentication token
Google Cloud Integration
# Authenticate with Google Cloud
echo '${{ secrets.GKE_SA_KEY }}' > key.json
gcloud auth activate-service-account --key-file=key.json
gcloud --quiet config set project ${{ secrets.GKE_PROJECT }}
gcloud --quiet auth configure-docker gcr.io
📊 Matrix Configuration
Parallel Execution
- 12 services build simultaneously using matrix strategy
- Independent builds - each service builds separately
🚀 Workflow Call Usage
jobs:
call-build-docker:
uses: ./.github/workflows/build.docker.yaml
with:
env: production
tag: ${{ github.ref_name }}
secrets: inherit
📋 Implementation Details
Service Configuration
Each service in the matrix has specific configuration:
- Build scripts: Define pre-build file copying operations
- Docker context: Service directory for build context
- Dockerfile: Specific Dockerfile name (including variants like
Dockerfile.general) - NPM authentication: Only
notificationsservice requires GitHub Packages access
Shared File Distribution
Most services require shared file copying before build:
- Copies from
/shared/*to service directories - Required for services with shared models and utilities
- Skipped for standalone services like
api-ai, utility services
Authentication Requirements
- GKE_SA_KEY: Google Cloud service account for registry access
- PACKAGE_TOKEN: GitHub Packages authentication for notifications service
- Secrets inheritance: All secrets passed from calling workflow
🔗 Related Workflows
- common.docker.yaml - Reusable Docker build template
- tag-trigger.yaml - Production deployment automation
- unit-tests.yml - Test services before building images