From 56926a7fed472e1e9fff15a3ec7139e60a489652 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 27 Apr 2021 12:11:33 -0700 Subject: [PATCH] examples/jamstack: use a inputs.yaml instead of cue code Signed-off-by: Sam Alba --- examples/README.md | 34 +++++++++---------- examples/jamstack/app_config.cue | 58 -------------------------------- examples/jamstack/backend.cue | 3 +- examples/jamstack/frontend.cue | 3 +- examples/jamstack/inputs.yaml | 34 +++++++++++++++++++ 5 files changed, 55 insertions(+), 77 deletions(-) delete mode 100644 examples/jamstack/app_config.cue create mode 100644 examples/jamstack/inputs.yaml diff --git a/examples/README.md b/examples/README.md index 6d40f92d..51a1a674 100644 --- a/examples/README.md +++ b/examples/README.md @@ -93,30 +93,30 @@ This app assumes the following infrastructure is available: - 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="" -AWS_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! +1. Create a new deployment from the plan ```sh cd ./examples/jamstack dagger new +``` + +2. Edit the inputs + +Edit the file `inputs.yaml` and review all values to match to your infrastructure. + +Add the inputs to the deployment: + +```sh +dagger input yaml "" -f ./inputs.yaml +``` + +1. Deploy! + +```sh 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: +The example `inputs.yaml` 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 diff --git a/examples/jamstack/app_config.cue b/examples/jamstack/app_config.cue deleted file mode 100644 index db7d44f9..00000000 --- a/examples/jamstack/app_config.cue +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "dagger.io/git" -) - -name: "my-app" - -// DISCLAIMER: all values below are fake and are provided as examples - -infra: { - awsConfig: { - accessKey: "" - secretKey: "" - region: "us-east-1" - } - vpcId: "vpc-020ctgv0bcde4242" - ecrRepository: "8563296674124.dkr.ecr.us-east-1.amazonaws.com/apps" - ecsClusterName: "bl-ecs-acme-764-ECSCluster-lRIVVg09G4HX" - elbListenerArn: "arn:aws:elasticloadbalancing:us-east-1:8563296674124:listener/app/bl-ec-ECSAL-OSYI03K07BCO/3c2d3e78347bde5b/d02ac88cc007e24e" - rdsAdminSecretArn: "arn:aws:secretsmanager:us-east-1:8563296674124:secret:AdminPassword-NQbBi7oU4CYS9-IGgS3B" - rdsInstanceArn: "arn:aws:rds:us-east-1:8563296674124:cluster:bl-rds-acme-764-rdscluster-8eg3xbfjggkfdg" - netlifyAccount: token: "" -} - -database: dbType: "mysql" - -backend: { - source: git.#Repository & { - remote: "https://github.com/blocklayerhq/acme-clothing.git" - ref: "HEAD" - subdir: "./crate/code/api" - } - - // DNS needs to be already configured to the ALB load-balancer - // and a valid certificate needs to be configured for that listener - hostname: "\(name).acme-764-api.microstaging.io" - - container: { - healthCheckPath: "/health-check" - healthCheckTimeout: 40 - } -} - -frontend: { - source: git.#Repository & { - remote: "https://github.com/blocklayerhq/acme-clothing.git" - ref: "HEAD" - subdir: "./crate/code/web" - } - - writeEnvFile: ".env" - - yarn: { - buildDir: "public" - script: "build:client" - } -} diff --git a/examples/jamstack/backend.cue b/examples/jamstack/backend.cue index 40458217..4932502f 100644 --- a/examples/jamstack/backend.cue +++ b/examples/jamstack/backend.cue @@ -3,12 +3,13 @@ package main import ( "dagger.io/dagger" "dagger.io/aws/ecs" + "dagger.io/git" ) // Backend configuration backend: { // Source code to build this container - source: dagger.#Artifact + source: git.#Repository | dagger.#Artifact // Container environment variables environment: [string]: string diff --git a/examples/jamstack/frontend.cue b/examples/jamstack/frontend.cue index 7e052f99..034f7c1d 100644 --- a/examples/jamstack/frontend.cue +++ b/examples/jamstack/frontend.cue @@ -4,11 +4,12 @@ import ( "dagger.io/dagger" "dagger.io/netlify" "dagger.io/js/react" + "dagger.io/git" ) frontend: { // Source code to build the app - source: dagger.#Artifact + source: git.#Repository | dagger.#Artifact writeEnvFile?: string diff --git a/examples/jamstack/inputs.yaml b/examples/jamstack/inputs.yaml new file mode 100644 index 00000000..fd9d0658 --- /dev/null +++ b/examples/jamstack/inputs.yaml @@ -0,0 +1,34 @@ +name: my-app +infra: + awsConfig: + accessKey: + secretKey: + region: us-east-1 + vpcId: vpc-020ctgv0bcde4242 + ecrRepository: 8563296674124.dkr.ecr.us-east-1.amazonaws.com/apps + ecsClusterName: bl-ecs-acme-764-ECSCluster-lRIVVg09G4HX + elbListenerArn: arn:aws:elasticloadbalancing:us-east-1:8563296674124:listener/app/bl-ec-ECSAL-OSYI03K07BCO/3c2d3e78347bde5b/d02ac88cc007e24e + rdsAdminSecretArn: arn:aws:secretsmanager:us-east-1:8563296674124:secret:AdminPassword-NQbBi7oU4CYS9-IGgS3B + rdsInstanceArn: arn:aws:rds:us-east-1:8563296674124:cluster:bl-rds-acme-764-rdscluster-8eg3xbfjggkfdg + netlifyAccount: + token: +database: + dbType: mysql +backend: + source: + remote: https://github.com/blocklayerhq/acme-clothing.git + ref: HEAD + subdir: ./crate/code/api + hostname: my-app.acme-764-api.microstaging.io + container: + healthCheckPath: /health-check + healthCheckTimeout: 40 +frontend: + source: + remote: https://github.com/blocklayerhq/acme-clothing.git + ref: HEAD + subdir: ./crate/code/web + writeEnvFile: .env + yarn: + buildDir: public + script: build:client