Deployment
Deployment guide for the RawStack API component.
The API is containerised and deployed to AWS ECS Fargate via the CDK infrastructure stack.
Build and push to ECR
Use the provided script from the repo root:
./scripts/push-api-to-ecr.sh
# Or with a specific tag:
./scripts/push-api-to-ecr.sh v1.2.3The script:
- Reads
AWS_REGION,AWS_ACCOUNT_ID, andCORE_ECR_REPOSITORY_NAMEfrominfrastructure/aws/.env - Builds the Docker image (multi-stage, Node 22 Alpine)
- Logs into ECR
- Creates the ECR repository if it doesn't exist
- Pushes the image
Auto-deployment
The CDK Core Stack deploys a Lambda function that listens for ECR PUSH events on the repository via EventBridge. When a new image is pushed, the Lambda triggers a new ECS deployment automatically — no manual ecs update-service required.
Dockerfile
The build uses a multi-stage Dockerfile:
- Builder stage — installs all dependencies, compiles TypeScript, generates Prisma client
- Production stage — copies only the compiled output and production
node_modules, keeping the image lean
At container startup, prisma migrate deploy runs before the NestJS application starts, ensuring migrations are always applied.
Environment variables in production
Sensitive values are injected as ECS task environment variables by the CDK stack. The CDK reads them from infrastructure/aws/.env at deploy time — never bake secrets into the image.
See Infrastructure deployment for the full variable reference.
Health check
The ALB health check hits GET /health. Ensure this endpoint returns 200 before marking tasks as healthy.