From 9cab6146ce33de93eb9cfe6fe3971a47a1839731 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 11 May 2021 15:03:28 -0700 Subject: [PATCH] examples/simple-s3: easier example to understand simple use case Signed-off-by: Sam Alba --- examples/README.md | 16 +++++++++------- examples/simple-s3/main.cue | 21 ++++++--------------- examples/simple-s3/website/index.html | 9 +++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 examples/simple-s3/website/index.html diff --git a/examples/README.md b/examples/README.md index 51a1a674..61df51a9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -25,20 +25,22 @@ dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY ``` -3. Deploy! +3. Specify the source code location + +```sh +dagger input dir source website +``` + +4. Deploy! ```sh dagger up ``` -4. Change a variable to alter the content - -In this example config, the HTML content is created from a variable `name` that has a default value, here is a simple -way to change it without changing the code: +5. Check the URL ```sh -dagger input text name "someone else!" -dagger up +curl -i $(dagger query url -f text) ``` ## Deploy a simple React application diff --git a/examples/simple-s3/main.cue b/examples/simple-s3/main.cue index 8600143e..24cf3dbf 100644 --- a/examples/simple-s3/main.cue +++ b/examples/simple-s3/main.cue @@ -3,6 +3,7 @@ package main import ( "dagger.io/aws" "dagger.io/aws/s3" + "dagger.io/dagger" ) // AWS Config for credentials and default region @@ -11,24 +12,14 @@ awsConfig: aws.#Config & { } // Name of the S3 bucket to use -bucket: *"hello-s3.infralabs.io" | string +bucket: *"dagger-io-examples" | string -name: string | *"world" - -page: """ - - - Simple static website on S3 - -

Hello!

-
  • Hey \(name)
  • - - """ +source: dagger.#Artifact +url: "\(deploy.url)index.html" deploy: s3.#Put & { config: awsConfig - sourceInline: page - always: true + "source": source contentType: "text/html" - target: "s3://\(bucket)/index.html" + target: "s3://\(bucket)/" } diff --git a/examples/simple-s3/website/index.html b/examples/simple-s3/website/index.html new file mode 100644 index 00000000..cdc7f010 --- /dev/null +++ b/examples/simple-s3/website/index.html @@ -0,0 +1,9 @@ + + +My Simple Website + +

    Shopping list

    +
  • Salad
  • +
  • Eggs
  • +
  • Potatoes
  • +