Browse documentation

This Website

Containerisation

Building a lightweight, repeatable runtime image for deployment.

The application is packaged as a Docker image to provide a consistent runtime environment across local development, CI/CD and AWS ECS. The build process produces a single immutable image that can be promoted between environments without modification.

Multi-stage Build

The Dockerfile uses a multi-stage build to separate dependency installation, application compilation and the final runtime image.

Only the standalone Next.js server and required static assets are copied into the production image.

FROM node:24-alpine AS runner
 
ENV NODE_ENV=production
 
USER nextjs
 
CMD ["node", "apps/portfolio-frontend/server.js"]
Tip

Next.js standalone output packages only the files required to run the application, avoiding the need to copy the full source tree or development dependencies into the final image.

Runtime Configuration

The production image is environment agnostic.

Configuration is supplied when the container starts rather than being embedded during the build process. This allows the same image to be deployed to different environments without rebuilding it.

Runtime configuration is injected by ECS using environment variables sourced from AWS Systems Manager Parameter Store. Sensitive values, such as the Resend API key, are stored as SecureString parameters, while non-sensitive configuration can use standard String parameters.

Note

Treat Docker images as immutable artifacts. Environment-specific configuration should be provided at runtime rather than baked into the image.

Amazon ECR

Built images are published to Amazon Elastic Container Registry (ECR).

Each image is tagged using the Git commit SHA and GitHub Actions run attempt, providing a direct relationship between a deployment and the source code that produced it while keeping every published tag unique.

ECS Task Definitions

Amazon ECS deploys containers using task definitions.

Each deployment registers a new task definition revision referencing the specific image stored in ECR. Updating a service simply involves deploying the new revision, allowing ECS to perform a rolling replacement of running tasks.

Deployment Flow

Diagram