Skip to content

Commit 85fbec8

Browse files
Agent Guidance & Sonar Scanner update (#122)
* chore: bump Sonar Scanner / Report Generator to latest * chore: add copilot instructions * chore: add comment about Dogfooding
1 parent 9ceb939 commit 85fbec8

File tree

4 files changed

+1140
-2
lines changed

4 files changed

+1140
-2
lines changed

.github/copilot-instructions.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Stacks Docker Images - AI Agent Guide
2+
3+
## Security and Compliance Requirements
4+
5+
⚠️ **CRITICAL**: Before making any changes to this repository, you MUST read and comply with the security guidelines in [copilot-security-instructions.md](./copilot-security-instructions.md). This includes requirements for GPG commit signing, branch protection policies, and security standards compliance.
6+
7+
## Project Overview
8+
9+
This repository builds a hierarchical set of Docker images for the Amido Stacks CI/CD pipeline. Images are layered from foundation to specialized tools, requiring careful build order and dependency management.
10+
11+
## Architecture & Build System
12+
13+
### Image Hierarchy
14+
15+
Images follow a strict dependency chain:
16+
17+
- **Foundation Layer**: `foundation/powershell``foundation/builder``foundation/azure-cli``foundation/tools`
18+
- **Specialized Images**: `java`, `dotnet`, `golang`, `node`, `infrastructure`, `inspec`, `data`, `kong`, `asciidoctor`
19+
- **Security Images**: `bottlerocket-cis-bootstrap`, `bottlerocket-cis-validation`
20+
21+
Each image inherits from a parent via ARG-based registry/tag system:
22+
23+
```dockerfile
24+
ARG REGISTRY=docker.io
25+
ARG IMAGE_TAG=0.0.1-workstation
26+
ARG ORG=ensono
27+
FROM ${REGISTRY}/${ORG}/eir-java:${IMAGE_TAG} AS base
28+
```
29+
30+
### Build Workflow (Taskctl)
31+
32+
All builds use `taskctl` with YAML configuration. Key patterns:
33+
34+
- **Foundation images**: Built locally first (no container dependency)
35+
- **Specialized images**: Built using `powershell_docker` context (inside `eir-foundation-builder`)
36+
- **Multi-platform**: Supports `linux/amd64` and `linux/arm64` via `PLATFORM` env var
37+
38+
**Critical build order**: Foundation images MUST build before dependent images.
39+
40+
```bash
41+
# Build foundation (local machine)
42+
taskctl build:foundation:powershell
43+
taskctl build:foundation:builder
44+
45+
# Build specialized (in container)
46+
taskctl build:dotnet
47+
taskctl build:java
48+
```
49+
50+
## Key Configuration Files
51+
52+
### `taskctl.yaml` - Build Orchestration
53+
54+
- Defines pipelines for each image with proper dependencies
55+
- Uses templated variables: `IMAGE_NAME`, `DOCKER_BUILD_ARGS`, `DOCKER_IMAGE_TAG`
56+
- Context switching between local (`powershell`) and containerized (`powershell_docker`) builds
57+
58+
### `build/taskctl/contexts.yaml` - Execution Environments
59+
60+
- `powershell_docker`: Runs inside `ensono/eir-foundation-builder` container
61+
- `powershell`: Runs on host machine with pwsh
62+
- `docsenv`: Uses `ensono/eir-asciidoctor` for documentation builds
63+
64+
### `build/scripts/Build-DockerImage.ps1` - Core Build Logic
65+
66+
- Handles multi-arch builds with platform-specific tagging
67+
- Registry authentication and image pushing
68+
- Uses `Invoke-External` wrapper for command execution
69+
- Tag format: `{registry}/{name}:{version}-{arch}`
70+
71+
## Development Patterns
72+
73+
### Adding New Images
74+
75+
1. Create `src/definitions/{name}/Dockerfile.ubuntu`
76+
2. Add `files/` directory with install scripts
77+
3. Update `taskctl.yaml` with new pipeline entry
78+
4. Add Azure DevOps stage in `build/azDevOps/docker-images.yml`
79+
5. Create documentation in `docs/docker-definitions/{name}.adoc`
80+
81+
**Security Note**: All changes must follow the branch protection workflow outlined in [copilot-security-instructions.md](./copilot-security-instructions.md). Never commit directly to protected branches or bypass GPG signing requirements.
82+
83+
### Version Management
84+
85+
- Image versions controlled by `DOCKER_IMAGE_TAG` environment variable
86+
- Component versions set as Dockerfile ARGs (e.g., `SONARSCANNER_VERSION=11.0.0`)
87+
- Foundation image versions referenced in dependent images via build args
88+
89+
### PowerShell Module Integration
90+
91+
Uses `EnsonoBuild` PowerShell module for:
92+
93+
- `Update-BuildNumber`: Sets `DOCKER_IMAGE_TAG`
94+
- `Invoke-External`: Command execution with dry-run support
95+
- `Invoke-Terraform`: Infrastructure management
96+
- `Confirm-Environment`: Environment validation
97+
98+
## Infrastructure & Deployment
99+
100+
### Azure Container Registry (ACR)
101+
102+
- Terraform configuration in `deploy/terraform/azure/acr/`
103+
- Environment variables prefixed with `TF_VAR_`
104+
- Required variables: `name_company`, `name_component`, `name_project`
105+
106+
### CI/CD Pipeline (Azure DevOps)
107+
108+
- Multi-stage pipeline with dependency management
109+
- Each image has dedicated stage with `dependsOn` relationships
110+
- Supports multi-platform builds and manifest creation
111+
- Documentation generation integrated into build process
112+
113+
## Dogfooding
114+
115+
- This repository attempts to use its own Docker images for builds and documentation generation wherever possible, ensuring that the images are robust and fit for purpose.
116+
117+
```powershell
118+
## Replace registry and tag
119+
$yqCommand = '.contexts.powershell_docker.executable.args[] |= select(contains("ensono/eir-foundation-builder")) = "{0}/ensono/eir-foundation-builder:{1}"' -f $DockerContainerRegistryName, $BuildNumber
120+
Write-Information ("Executing yq with '{0}'" -f $yqCommand)
121+
yq -i $yqCommand build/taskctl/contexts.yaml
122+
```
123+
124+
## Documentation System
125+
126+
- AsciiDoc-based using custom `ensono/eir-asciidoctor` image
127+
- Configuration in `docs.json` with PDF/HTML output
128+
- Auto-generates Docker Hub README files from AsciiDoc sources
129+
- Custom glob-include processor for dynamic content inclusion
130+
131+
## Common Debugging Commands
132+
133+
```bash
134+
# Check image dependencies
135+
taskctl build:foundation:powershell --dry-run
136+
137+
# Debug build in container context
138+
docker run --rm -v ${PWD}:/app -w /app ensono/eir-foundation-builder:latest pwsh
139+
140+
# Generate docs locally
141+
taskctl docs
142+
143+
# Validate Terraform configuration
144+
taskctl infrastructure_variables
145+
taskctl infra:plan
146+
```
147+
148+
## Environment Variables
149+
150+
- `DOCKER_IMAGE_TAG`: Version for all images (set by `Update-BuildNumber`)
151+
- `DOCKER_CONTAINER_REGISTRY_NAME`: Target registry (default: docker.io)
152+
- `PLATFORM`: Build architecture (linux/amd64, linux/arm64)
153+
- `TF_VAR_*`: Terraform variables for ACR deployment

0 commit comments

Comments
 (0)