Docker Update Guide for AI Agents
Overview
This guide provides step-by-step instructions for AI agents to update the OASIS API Docker image and deploy it to AWS ECS. Follow these steps whenever code changes are made that require a new Docker build.
Quick Reference: Complete Update Process
# 1. Navigate to project root
cd /Volumes/Storage/OASIS_CLEAN
# 2. Build and push Docker image to AWS ECR
./docker/deploy.sh
# 3. Update ECS service to use new image
./docker/update-ecs.shThat's it! The scripts handle everything automatically.
Detailed Process
Step 1: Build and Push Docker Image
Script: ./docker/deploy.sh
What it does:
Authenticates with AWS ECR
Checks/creates ECR repository if needed
Builds Docker image from
docker/DockerfileTags image with both
latestand version tag (e.g.,v20251220-003204)Pushes both tags to AWS ECR
Outputs image digest for reference
Location: Run from project root (/Volumes/Storage/OASIS_CLEAN)
Expected Output:
Common Issues:
Docker not running: Start Docker Desktop
AWS credentials not configured: Run
aws configureBuild fails: Check Docker logs, ensure all dependencies are present
No space on device: Run
docker system prune -ato free space
Step 2: Update ECS Service
Script: ./docker/update-ecs.sh [optional-image-tag]
What it does:
Retrieves current ECS task definition
Updates task definition with new Docker image
Registers new task definition revision
Updates ECS service to use new task definition
Waits for service to stabilize
Location: Run from project root (/Volumes/Storage/OASIS_CLEAN)
Usage:
Expected Output:
Service Details:
Cluster:
oasis-api-clusterService:
oasis-api-serviceTask Family:
oasis-api-taskRegion:
us-east-1
When to Update Docker
Update Docker whenever:
Code changes are made to:
ONODE/NextGenSoftware.OASIS.API.ONODE.WebAPI/(WebAPI project)ONODE/NextGenSoftware.OASIS.API.ONODE.Core/(Core project)OASIS Architecture/(Core OASIS libraries)Providers/(Provider implementations)
Configuration changes in:
appsettings.jsonorappsettings.Production.jsonOASIS_DNA.json(if included in image)Dockerfileitself
Dependency updates:
NuGet package updates
External library changes
.NET SDK/runtime updates
New features requiring:
New endpoints
New services
New dependencies
Docker Configuration
Dockerfile Location
Path:
docker/DockerfileBuild Context: Project root (
/Volumes/Storage/OASIS_CLEAN)
Key Configuration
Base Images:
Runtime:
mcr.microsoft.com/dotnet/aspnet:9.0Build:
mcr.microsoft.com/dotnet/sdk:9.0
Ports:
Container:
80(HTTP)Health Check:
http://localhost:80/swagger/index.html
Environment Variables:
ASPNETCORE_ENVIRONMENT=ProductionASPNETCORE_URLS=http://+:80
Build Process:
Copy external libraries (
External Libs/,external-libs/,NextGenSoftware-Libraries/)Copy project files (
.csprojfiles)Copy source code
Restore NuGet packages
Build solution
Publish WebAPI project
Copy published files to runtime image
AWS Configuration
ECR Repository
URI:
881490134703.dkr.ecr.us-east-1.amazonaws.com/oasis-apiRegion:
us-east-1Account ID:
881490134703
ECS Configuration
Cluster:
oasis-api-clusterService:
oasis-api-serviceTask Definition:
oasis-api-taskLoad Balancer:
oasis-api-alb-2011847064.us-east-1.elb.amazonaws.comTarget Group:
oasis-api-tg-v5
Domain
API Domain:
api.oasisweb4.comPoints to ALB β ECS service
Testing After Update
1. Check ECS Service Status
Expected: RunningCount should equal DesiredCount (typically 1)
2. Check Running Task
Expected: LastStatus should be RUNNING, Image should match the new image
3. Test API Endpoint
Troubleshooting
Build Fails
Issue: Docker build fails with compilation errors
Solution:
Check build logs for specific errors
Ensure all project references are correct
Verify
.csprojfiles don't reference excluded projectsCheck that all required files are in build context
Common Build Errors:
Missing project references β Check
.csprojfilesSTARNET dependencies β Already excluded, should not appear
Missing external libraries β Ensure
External Libs/andexternal-libs/are copied
Push Fails
Issue: docker push fails with authentication error
Solution:
ECS Service Won't Update
Issue: Service update fails or doesn't start new tasks
Solution:
Check task definition for errors:
Check service events:
Check task logs:
API Not Responding
Issue: After update, API returns errors or doesn't respond
Solution:
Check if service is running:
Check task logs for errors:
Verify image was built correctly:
Rollback to previous version if needed:
Local Testing Before Deployment
Build Locally
Run Locally
Test Script
Use the provided test script:
Build Optimization
Docker Build Cache
Docker uses layer caching. To force a clean build:
Build Context Size
The build context includes the entire project. To reduce size:
Check
.dockerignoreexcludes unnecessary filesEnsure
bin/,obj/,.git/are excludedLarge directories like
holochain-client-csharp/should be excluded
Build Time
Typical build times:
First build: 20-30 minutes (downloads all dependencies)
Incremental build: 5-15 minutes (uses cache)
Clean build: 20-30 minutes
To speed up:
Use Docker BuildKit:
DOCKER_BUILDKIT=1 docker build ...Use build cache mount (if supported)
Rollback Procedure
If a deployment causes issues:
1. Identify Previous Working Version
2. Get Previous Task Definition
3. Rollback Service
Important Files
Scripts
docker/deploy.sh- Build and push to ECRdocker/update-ecs.sh- Update ECS servicedocker/test-local.sh- Test Docker image locallydocker/build.sh- Build locally only
Configuration
docker/Dockerfile- Docker build instructions.dockerignore- Files to exclude from builddocker/docker-compose.yml- Local development setup
Documentation
docker/README.md- General Docker documentationdocker/AGENT_DOCKER_UPDATE_GUIDE.md- This file (for AI agents)DOCKER_DEPLOYMENT_GUIDE.md- General deployment guide
Checklist for AI Agents
Before updating Docker:
During update:
After update:
Summary
To update Docker:
./docker/deploy.sh- Builds and pushes image./docker/update-ecs.sh- Updates ECS service
Total time: ~25-35 minutes (build) + ~2-5 minutes (deploy)
Verification: Test http://api.oasisweb4.com/api/avatar/health
The scripts handle all the complexity automatically. Just run them in order from the project root.
Last updated