Skip to main content
Version: Latest

Deploying NocoDB on AWS ECS (Fargate)

This guide will walk you through deploying NocoDB on Amazon ECS using Fargate.

Prerequisites

  • AWS CLI configured with appropriate permissions
  • Basic understanding of AWS ECS and Fargate

Deployment Steps

  1. Create ECS Cluster

      aws ecs create-cluster --cluster-name <YOUR_ECS_CLUSTER>
  2. Create a Log Group:

    aws logs create-log-group --log-group-name /ecs/<YOUR_APP_NAME>/<YOUR_CONTAINER_NAME>
  3. Create an ECS Task Definition:

    Every time you create it, it will add a new version. If it is not existing, the version will be 1.

    aws ecs register-task-definition --cli-input-json file://task-definition.json
    tip

    This json file defines the container specification. You can define secrets such as NC_DB and environment variables here.

    Example task-definition.json:

        {
    "family": "nocodb-sample-task-def",
    "networkMode": "awsvpc",
    "containerDefinitions": [
    {
    "name": "<YOUR_CONTAINER_NAME>",
    "image": "nocodb/nocodb:latest",
    "essential": true,
    "logConfiguration": {
    "logDriver": "awslogs",
    "options": {
    "awslogs-group": "/ecs/<YOUR_APP_NAME>/<YOUR_CONTAINER_NAME>",
    "awslogs-region": "<YOUR_AWS_REGION>",
    "awslogs-stream-prefix": "ecs"
    }
    },
    "secrets": [
    {
    "name": "<YOUR_SECRETS_NAME>",
    "valueFrom": "<YOUR_SECRET_ARN>"
    }
    ],
    "environment": [
    {
    "name": "<YOUR_ENV_VARIABLE_NAME>",
    "value": "<YOUR_ENV_VARIABLE_VALUE>"
    }
    ],
    "portMappings": [
    {
    "containerPort": 8080,
    "hostPort": 8080,
    "protocol": "tcp"
    }
    ]
    }
    ],
    "requiresCompatibilities": [
    "FARGATE"
    ],
    "cpu": "256",
    "memory": "512",
    "executionRoleArn": "<YOUR_ECS_EXECUTION_ROLE_ARN>",
    "taskRoleArn": "<YOUR_ECS_TASK_ROLE_ARN>"
    }
  4. Create an ECS Service:

    aws ecs create-service \
    --cluster <YOUR_ECS_CLUSTER> \
    --service-name <YOUR_SERVICE_NAME> \
    --task-definition <YOUR_TASK_DEF>:<YOUR_TASK_DEF_VERSION> \
    --desired-count <DESIRED_COUNT> \
    --launch-type "FARGATE" \
    --platform-version <VERSION> \
    --health-check-grace-period-seconds <GRACE_PERIOD_IN_SECOND> \
    --network-configuration "awsvpcConfiguration={subnets=["<YOUR_SUBSETS>"], securityGroups=["<YOUR_SECURITY_GROUPS>"], assignPublicIp=ENABLED}" \
    --load-balancer targetGroupArn=<TARGET_GROUP_ARN>,containerName=<CONTAINER_NAME>,containerPort=<YOUR_CONTAINER_PORT>
tip

If your service fails to start, you may check the logs in ECS console or in Cloudwatch. Generally it fails due to the connection between ECS container and NC_DB. Make sure the security groups have the correct inbound and outbound rules.

Important Notes

  • Ensure that your security groups have the correct inbound and outbound rules.
  • The NC_DB environment variable should be properly set to connect to your database.
  • Monitor the ECS console and CloudWatch logs for any deployment issues.
  • You can customize the task definition and service configuration based on your requirements.