Usage

0. If using docker instead of dgctl installation

Prepend any "dgctl" command with following docker command
docker run -v /<PATH_TO_YOUR_APP_FOLDER>:/app -v /<PATH_TO_AWS_CONFIGURATION>:/root/.aws -ti dockerdiggerorg/dgctl
For example to run init
docker run -v /Users/digger/infra:/app -v /Users/digger/.aws:/root/.aws -ti dockerdiggerorg/dgctl init

1. Clone the repository

git clone https://github.com/diggerhq/a-nodeapp
cd a-nodeapp

2. Initialise Digger project

Create infra directory at the top level of your repository and cd into it:
mkdir infra && cd infra
Now run the init command:
dgctl init
This should create the following file structure under the infra folder:
.
├── default_network
│   ├── config.json
│   └── overrides
├── dgctl.json
└── overrides

3. Add a container block

dgctl block add --type=container myApp
A new block will be added into dgctl.json and a new myApp directory will be created next to it:
.
├── default_network
│   ├── config.json
│   └── overrides
├── dgctl.json
├── myApp
│   ├── config.json
│   └── overrides
└── overrides

4. Build your infrastructure for AWS

dgctl generate --platform=AWS
A new generated folder will be created, containing a complete set of Terraform templates needed to run your stack on AWS
.
├── README.md
├── default_network
│   ├── main.tf
│   ├── outputs.tf
│   ├── variables.tf
│   └── vpc.tf
├── main.tf
└── myApp
├── cluster.tf
├── ecr.tf
├── ecs.tf
├── ecs_task_execution_policy.json
├── ecs_task_policy.json
├── lb.tf
├── main.tf
├── outputs.tf
├── securitygroup.tf
├── variables.tf
└── vpc.tf
If you are not familiar with Terraform - don't worry, you don't need to learn it! Terraform is used as an "assembly language" that Digger compiles into. You can add your own Terraform or customise it completely, but you don't have to; it works as-is.

5. Provision resources on AWS

dgctl provision
It will ask for your AWS key pair and save it in ~/.aws/credentials if you don't have it there
Then it will provision your infrastructure using terraform under the hood (plan and apply)
This may take a few minutes ☕

6. Deploy your application code

dgctl block deploy myApp --context=../
Or you can cd .. and run dgctl block deploy myApp --context=. from the parent directory
This will run docker build, docker push and update the task definition in AWS ECS
You can customise the script in the config.json file of a corresponding block
The block deploy command is only a convenience shortcut; it is not meant to be used in production scenarios. In CI pipelines we recommend using docker and aws commands directly. ECR repository URL can be obtained by running dgctl block info command.
​
TODO: get rid of cd'ing into infra directory. The CLI should create infra dir and operate from the root dir instead.