Optional: Install sql-over-http​ for AWS Fargate

💡Note

Step 1. Prepare the sql-over-http Docker image 

Again, to make things a little easier, we copy the image from Docker Hub into an ECR repository:

aws --profile test ecr create-repository --repository-name sql-over-http

# Replace this with the address of the registry output in the previous command:
REGISTRY=306378194054.dkr.ecr.eu-west-1.amazonaws.com

aws ecr get-login-password --region eu-west-1 | \
  docker login --username AWS --password-stdin $REGISTRY

SOH_IMAGE=sql-over-http:latest

docker pull tines/$SOH_IMAGE
docker tag tines/$SOH_IMAGE $REGISTRY/$SOH_IMAGE
docker push $REGISTRY/$SOH_IMAGE

Step 2. Update the ECS task definitions 

To make it easy to access, we simply deploy the sql-over-http container alongside the existing containers by adding them to the tines-app and tines-sidekiq tasks. (sql-over-http is completely stateless, so running two instances is easiest.)

The command below repeats what we did in step 10 above, but adds the following container definition to both tasks:

{
  "name": "sql-over-http",
  "image": "$REGISTRY/sql-over-http:latest",
  "environment": [
    {
      "name": "PORT",
      "value": "4000"
    }
  ],
  "logConfiguration": {
    "logDriver": "awslogs",
    "options": {
      "awslogs-group": "tines",
      "awslogs-region": "$AWS_REGION",
      "awslogs-stream-prefix": "tines"
    }
  },
  "portMappings": [
    {
      "containerPort": 4000
    }
  ]
}
# Replace this with the ARN of the role you created in step 9:
EXECUTION_ROLE_ARN=arn:aws:iam::306378194054:role/tinesTaskExecutionRole

# Replace this with the address of the registry as established in step 2:
REGISTRY=306378194054.dkr.ecr.eu-west-1.amazonaws.com

# Replace this with the name of the image you added to the registry in step 2:
IMAGE=tines-app:de4875d_v4.2.0

# Replace this with the name of the image you added to the registry in step A1:
SOH_IMAGE=sql-over-http:latest

# Replace this with the name of the bucket you created in step 8:
ENV_FILE_S3_BUCKET=tines-test-env

# Replace this with the name of AWS region you're running Tines in:
AWS_REGION=eu-west-1

aws ecs register-task-definition \
  --family "tines-app" \
  --memory 2048 \
  --network-mode awsvpc \
  --cpu 1024 \
  --execution-role-arn $EXECUTION_ROLE_ARN \
  --container-definitions '[{"name": "tines-app", "command": ["start-tines-app"], "image": "'$REGISTRY'/'$IMAGE'", "environmentFiles": [{"value": "arn:aws:s3:::'$ENV_FILE_S3_BUCKET'/tines.env", "type": "s3"}], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "tines", "awslogs-region": "'$AWS_REGION'", "awslogs-stream-prefix": "tines" }}, "portMappings": [{"containerPort": 3000}]},{"name": "sql-over-http", "image": "'$REGISTRY'/'$SOH_IMAGE'", "environment": [{"name": "PORT", "value": "4000"}], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "tines", "awslogs-region": "'$AWS_REGION'", "awslogs-stream-prefix": "tines" }}, "portMappings": [{"containerPort": 4000}]}]'

aws ecs register-task-definition \
  --family "tines-sidekiq" \
  --memory 2048 \
  --network-mode awsvpc \
  --cpu 1024 \
  --execution-role-arn $EXECUTION_ROLE_ARN \
  --container-definitions '[{"name": "tines-sidekiq", "command": ["start-tines-sidekiq"], "image": "'$REGISTRY'/'$IMAGE'", "environmentFiles": [{"value": "arn:aws:s3:::'$ENV_FILE_S3_BUCKET'/tines.env", "type": "s3"}], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "tines", "awslogs-region": "'$AWS_REGION'", "awslogs-stream-prefix": "tines" }}},{"name": "sql-over-http", "image": "'$REGISTRY'/'$SOH_IMAGE'", "environment": [{"name": "PORT", "value": "4000"}], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "tines", "awslogs-region": "'$AWS_REGION'", "awslogs-stream-prefix": "tines" }}, "portMappings": [{"containerPort": 4000}]}]'

Step 3. Restart the services 

If you delete the tines-app and tines-sidekiq services via the UI, you can then re-run the commands from step 12.

The one thing you'll need to change:

  --task-definition tines-app:1
  --task-definition tines-sidekiq:1

...will need to be incremented to reflect the latest versions of the task definitions, following the update that happened in step A2

  --task-definition tines-app:2
  --task-definition tines-sidekiq:2

Step 4. Access sql-over-http from within Tines 

From within Tines, sql-over-http will be accessible at http://localhost:4000/.

Was this helpful?