Skip to content

shgtkshruch/chronos

Repository files navigation

chronos

Build

$ COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build

Build docker image for production.

$ docker build -f Dockerfile.prod --secret id=master_key,src=config/master.key .

Dev

$ docker-compose up -d

AWS

IAM Policy

IAM policy for Copilot deployment.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "iam:*",
                "servicediscovery:*",
                "route53domains:*",
                "s3:*",
                "ssm:*",
                "ecs:*",
                "lambda:*",
                "route53:*",
                "cloudformation:*",
                "ecr:*",
                "ec2:*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "*"
        }
    ]
}

Nginx

Build Nginx docker image, and push to ECR.

./scripts/ecr-nginx.sh

Copilot

Create AWS resources (ex. VPC, ALB, Farge, RDS) with AWS Copilot.

$ ./scripts/copilot-init.sh <env> <domain>

Shared EFS

To share EFS between services, fetch EFS configuration from copilot commands bellow.

$ FS_ID=$(copilot env show -n dev --json --resources | jq -r '.resources[] | select(.type | contains("EFS::FileSystem")) | .physicalID')
$ FS_AP=$(copilot svc show -n rails --json --resources | jq -r '.resources.dev[] | select(.type | contains("EFS::AccessPoint")) | .physicalID')

And set these values to storage section.

storage:
  volumes:
    sharedEFS:
      efs:
        id: $FS_ID
        auth:
          access_point_id: $FS_AP
          iam: true
      path: /app/public/maintenance
      read_only: false

Switch maintenance

# turn on maintenance mode
$ copilot svc exec --app chronos --command 'bin/maintenance on'

# turn off maintenance mode
$ copilot svc exec --app chronos --command 'bin/maintenance off'

Cleaning

$ ./scripts/copilot-delete.sh

Deployment

Running a deployment workflow using GitHub CLI.

./scripts/deploy.sh -h
Usage: ./scripts/deploy.sh [flags]

    -r, --rails          Deploy Rails
    -n, --nuxt           Deploy Nuxt
    -m, --maintenance    Maintenance mode on
    --branch string      Deploy branch name
    --env string         Deploy environment. dev | staging | production