examples/jamstack: added README and example app config

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba
2021-04-13 15:32:23 -07:00
parent 41f78d948e
commit a9f76268a2
3 changed files with 113 additions and 8 deletions

View File

@@ -29,14 +29,14 @@ dagger new
```
3. Configure the deployment with your Netlify access token.
You can create new tokens from the [Netlify dashboard](https://app.netlify.com/user/applications/personal).
You can create new tokens from the [Netlify dashboard](https://app.netlify.com/user/applications/personal).
```sh
dagger input text www.account.token MY_TOKEN
```
*NOTE: there is a dedicated command for encrypted secret inputs, but it is
not yet implemented. Coming soon!*
_NOTE: there is a dedicated command for encrypted secret inputs, but it is
not yet implemented. Coming soon!_
4. Deploy!
@@ -44,6 +44,53 @@ not yet implemented. Coming soon!*
dagger up
```
## Deploy a complete JAMstack app
This example shows how to deploy a complete app with a backend, a database and a frontend.
This app assumes the followinf infrastructure is available:
- AWS ECS Cluster
- AWS ALB with a TLS certificate
- AWS RDS Instance (MySQL or PostgreSQL)
- AWS ECR repository
1. Prepare the app configuration
Edit the file `./examples/jamstack/app_config.cue` and review all values to match to your own needs.
2. Login your local docker daemon to ECR
_This step is temporary and will be removed soon (gh issue #301)._
```sh
AWS_REGION="<REPLACE_WITH_AWS_REGION>"
AWS_ID="<REPLACE_WITH_AWS_ACCOUNT_ID>"
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "${AWS_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
```
3. Deploy!
```sh
cd ./examples/jamstack
dagger new
dagger up
```
The example `app_config.cue` from the `./examples/jamstack` directory takes the source code from a remote git repository,
but you can remove this from the file and instead points to a local source code:
```sh
dagger input dir backend.source ./my/local/backend/code
```
And the same mechanism applies for every single key in this file.
4. Get the App URL
```sh
dagger query url
```
## Provision a Kubernetes cluster on AWS
@@ -79,7 +126,6 @@ dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
```
4. Deploy!
```sh
@@ -103,7 +149,6 @@ Components:
- [Amazon Cloudwatch Synthetics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) for hosting the monitoring scripts
- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning
1. Change the current directory to the example deployment plan
```sh
@@ -142,7 +187,6 @@ dagger input text email my_email@my_domain.tld
dagger up
```
## Deploy an application to your Kubernetes cluster
This example shows two different ways to deploy an application to an existing Kubernetes cluster: with and without a Helm chart. Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/kubernetes-app)
@@ -157,7 +201,6 @@ Components:
How to run:
1. Change the current directory to the example deployment plan
```sh