Skip to main content

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 NameContextBuild ScriptDockerfile
api-internal./internalcp -r shared/* internal/api/v1Dockerfile
api-external./externalcp -r shared/* external/IntegrationsDockerfile
api-ai./ai-service(none)Dockerfile

Gateway & Communication

Service NameContextBuild ScriptDockerfile
dashboard-gateway./dashboard-gatewaycp -r shared/* dashboard-gatewayDockerfile
socket-conversation./conversation-socketcp -r shared/* conversation-socket && node common/indexDockerfile
socket-general./general-socketcp -r shared/* general-socketDockerfile

Background Processing

Service NameContextBuild ScriptDockerfile
queue-manager-general./queue-managercp -r shared/* queue-managerDockerfile.general
queue-manager-puppeteer./queue-managercp -r shared/* queue-managerDockerfile.puppeteer
notifications./notifications(none)Dockerfile

Utility Services

Service NameContextBuild ScriptDockerfile
callrail-proxy./misc/callrail-recordings(none)Dockerfile
currency-converter./misc/currency(none)Dockerfile
misc-proxy./misc/proxy-server(none)Dockerfile

🔄 Build Process

Job Flow

  1. Set Sandbox ID: Display the build tag for identification
  2. Matrix Build: Execute parallel builds for all 12 services
  3. Shared File Distribution: Copy shared models and utilities to service directories
  4. 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.3
  • gcr.io/dash-208313/dashclicks-staging-socket-conversation:feature-123
  • gcr.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 notifications service 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

💬

Documentation Assistant

Ask me anything about the docs

Hi! I'm your documentation assistant. Ask me anything about the docs!

I can help you with:
- Code examples
- Configuration details
- Troubleshooting
- Best practices

Try asking: How do I configure the API?
09:31 AM