SolidX
ReferenceGoing Live

ECS

A comprehensive guide for deploying SolidX applications to Amazon ECS with Fargate.

Mental Model

ECS with Fargate is the managed-container version of the Docker deployment story.

  • You still package the application as containers.
  • AWS takes over the responsibility of running those containers on infrastructure you do not manage directly.
  • The operational focus shifts from server administration to cloud resources, networking, services, and load balancing.

ECS and Fargate let you keep container discipline while outsourcing server management to AWS.

This guide will walk you through deploying your SolidX application to Amazon Elastic Container Service (ECS) with Fargate, a serverless compute engine that allows you to run containers without managing the underlying infrastructure.

Prerequisites

Before you begin, make sure you have:

  • An AWS account.
  • AWS CLI installed and configured.
  • Docker available locally for image builds.

1. Containerize and Push to ECR

First, containerize the application and push the images to Amazon Elastic Container Registry (ECR).

Create ECR Repositories

Create ECR repositories for both the backend and frontend:

aws ecr create-repository --repository-name solidx-api --region <your-region>
aws ecr create-repository --repository-name solidx-ui --region <your-region>

Authenticate Docker to ECR

Authenticate your Docker client to your ECR registry:

aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com

Build, Tag, and Push Images

Build, tag, and push the Docker images for both services.

cd solid-api
docker build -t <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-api:latest .
docker push <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-api:latest
cd ../solid-ui
docker build -t <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-ui:latest .
docker push <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-ui:latest

2. Set Up ECS Resources

Next, create the ECS resources required to run the application.

Create an ECS Cluster

Create an ECS cluster to host your services:

aws ecs create-cluster --cluster-name solidx-cluster --region <your-region>

Create Task Definitions

Create task definitions for the backend and frontend. A task definition is a blueprint for your application.

Create a solidx-api-task-definition.json file:

{
    "family": "solidx-api-task",
    "networkMode": "awsvpc",
    "containerDefinitions": [
        {
            "name": "solidx-api",
            "image": "<your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-api:latest",
            "portMappings": [
                {
                    "containerPort": 3000,
                    "hostPort": 3000
                }
            ],
            "essential": true
        }
    ],
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "cpu": "256",
    "memory": "512"
}

Create a solidx-ui-task-definition.json file:

{
    "family": "solidx-ui-task",
    "networkMode": "awsvpc",
    "containerDefinitions": [
        {
            "name": "solidx-ui",
            "image": "<your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/solidx-ui:latest",
            "portMappings": [
                {
                    "containerPort": 3001,
                    "hostPort": 3001
                }
            ],
            "essential": true
        }
    ],
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "cpu": "256",
    "memory": "512"
}

Now, register the task definitions with ECS:

aws ecs register-task-definition --cli-input-json file://solidx-api-task-definition.json --region <your-region>
aws ecs register-task-definition --cli-input-json file://solidx-ui-task-definition.json --region <your-region>

3. Create Services and Load Balancer

Use an Application Load Balancer (ALB) to route traffic to your services.

Create an ALB and Target Groups

  1. Create a security group for the ALB.
  2. Create an Application Load Balancer.
  3. Create target groups for solidx-api and solidx-ui.
  4. Create listeners to forward traffic to the correct target groups.

Create ECS Services

Create the services that will run and maintain your tasks.

Create a solidx-api-service.json file:

{
    "cluster": "solidx-cluster",
    "serviceName": "solidx-api-service",
    "taskDefinition": "solidx-api-task",
    "desiredCount": 1,
    "launchType": "FARGATE",
    "networkConfiguration": {
        "awsvpcConfiguration": {
            "subnets": ["<your-subnet-id-1>", "<your-subnet-id-2>"],
            "securityGroups": ["<your-security-group-id>"],
            "assignPublicIp": "ENABLED"
        }
    },
    "loadBalancers": [
        {
            "targetGroupArn": "<your-api-target-group-arn>",
            "containerName": "solidx-api",
            "containerPort": 3000
        }
    ]
}

Create a solidx-ui-service.json file:

{
    "cluster": "solidx-cluster",
    "serviceName": "solidx-ui-service",
    "taskDefinition": "solidx-ui-task",
    "desiredCount": 1,
    "launchType": "FARGATE",
    "networkConfiguration": {
        "awsvpcConfiguration": {
            "subnets": ["<your-subnet-id-1>", "<your-subnet-id-2>"],
            "securityGroups": ["<your-security-group-id>"],
            "assignPublicIp": "ENABLED"
        }
    },
    "loadBalancers": [
        {
            "targetGroupArn": "<your-ui-target-group-arn>",
            "containerName": "solidx-ui",
            "containerPort": 3001
        }
    ]
}

Now, create the services:

aws ecs create-service --cli-input-json file://solidx-api-service.json --region <your-region>
aws ecs create-service --cli-input-json file://solidx-ui-service.json --region <your-region>

4. Verify Your Deployment

Once the services are running, access the application through the DNS name of your Application Load Balancer.

You can find the ALB DNS name in the AWS console under Load Balancers.

Production Readiness

Before treating the deployment as production-ready, make sure you also define:

  • Secure environment variable handling.
  • Database connectivity and secret storage.
  • Health checks and autoscaling rules.
  • HTTPS termination and DNS routing.

At this point, the application is running in a managed AWS container environment without requiring direct server administration.