Skip to content

CLI deploy

Naomichi Yamakita edited this page Oct 30, 2024 · 19 revisions

In order to deploy an application, you need to create a proper deployment configuration file in advance.

List of commands

docker compose run --rm rails thor list

deploy
------
thor deploy help [COMMAND]                              # Describe subcommands or one specific subcommand
thor deploy run_task -r, --repository=REPOSITORY        # Execute run task.
thor deploy scheduled_task -r, --repository=REPOSITORY  # Update scheduled task.
thor deploy service -r, --repository=REPOSITORY         # Update service task.
thor deploy workflow                                    # Execute step deployment using workflow.

genova
------
thor genova:deploy   # Deploy application to Amazon ECS.
thor genova:utils    # Provides useful utilities related to deployment.
thor genova:version  # Show version.

utils
-----
thor utils decrypt --value=VALUE                                  # Decrypt a value encrypted with KMS (now deprecated).
thor utils delete_invalid_jobs                                    # Delete invalid and inconsistent jobs (jobs older than 1 week).
thor utils delete_old_images                                      # Delete the old image used by genova for build.
thor utils delete_transaction -r, --repository=REPOSITORY         # Cancel deploy transactions.
thor utils encrypt --value=VALUE                                  # Encrypt a string specified in the argument using KMS (now deprecated).
thor utils help [COMMAND]                                         # Describe subcommands or one specific subcommand
thor utils register_task --path=PATH -r, --repository=REPOSITORY  # Register task definition.

Update service

# Help
docker compose run --rm rails thor genova:deploy help service

# Execution
docker compose run --rm rails thor genova:deploy service -r {repository} -c {cluster} -s {service}

# Execution example
docker compose run --rm rails thor genova:deploy service -r api -c production-app -s backend

Update scheduled task

# Help
docker compose run --rm rails thor genova:deploy help scheduled-task

# Execution
docker compose run --rm rails thor genova:deploy scheduled-task -r {repository} -c {cluster} --scheduled_task_rule={scheduled_task_rule} --scheduled_task_target={scheduled_task_target}

# Execution example
docker compose run --rm rails thor genova:deploy scheduled-task -r api -c production-app --scheduled_task_rule=sitemap_refresh --scheduled_task_target=production

Execute the Run task

# Help
docker compose run --rm rails thor genova:deploy help run-task

# Execution
docker compose run --rm rails thor genova:deploy run-task -r {repository} -c {cluster} --run-task {run task}

# Execution example
docker compose run --rm rails thor genova:deploy run-task -r api -c production-app --run-task greeting
docker compose run --rm rails thor genova:deploy run-task -r api -c production-app --run-task greeting --override-container rails --override-command db:migrate

Tips

Force deploy

genova clones the repository locally, then checks out the branch to be deployed and builds the Docker file. The process from repository clone to build is transaction-managed and automatically locked if a separate deploy request for the same repository is executed (the lock wait time defaults to 1,200 seconds and can be changed via config/settings.local.yml).

In some situations, you may want to deploy the same image to multiple clusters or services. In such cases, you can add --force (or -f) to the deploy command to disable transactions and allow parallel builds, thus improving performance.

# Example
docker compose run --rm rails thor genova:deploy service -r api -c production-app -s backend --force

Note, however, that genova creates only one local repository per repository, so deploying different branches in parallel to the same repository may cause unexpected behavior.