examples: added simple s3 for static website example
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
413017f7cb
commit
39f7170cc5
@ -3,6 +3,44 @@
|
|||||||
All example commands should be executed in the `examples/` directory
|
All example commands should be executed in the `examples/` directory
|
||||||
in an up-to-date checkout of the [dagger repository](https://github.com/dagger/dagger).
|
in an up-to-date checkout of the [dagger repository](https://github.com/dagger/dagger).
|
||||||
|
|
||||||
|
## Deploy a static page to S3
|
||||||
|
|
||||||
|
This example shows how to generate a simple HTML page and serve it from an S3 bucket.
|
||||||
|
|
||||||
|
Components:
|
||||||
|
|
||||||
|
- [Amazon S3](https://aws.amazon.com/s3/) for hosting
|
||||||
|
|
||||||
|
1. Change the current directory to the example deployment plan and create a new deployment
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./simple-s3
|
||||||
|
dagger new
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Configure your AWS credentials
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
||||||
|
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 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:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dagger input text name "someone else!"
|
||||||
|
dagger up
|
||||||
|
```
|
||||||
|
|
||||||
## Deploy a simple React application
|
## Deploy a simple React application
|
||||||
|
|
||||||
This example shows how to deploy an example React Application. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/react)
|
This example shows how to deploy an example React Application. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/react)
|
||||||
@ -120,9 +158,6 @@ dagger new
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -165,9 +200,6 @@ dagger new
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -217,9 +249,6 @@ dagger new
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
|
||||||
```
|
```
|
||||||
|
|
||||||
|
33
examples/simple-s3/main.cue
Normal file
33
examples/simple-s3/main.cue
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/aws"
|
||||||
|
"dagger.io/aws/s3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AWS Config for credentials and default region
|
||||||
|
awsConfig: aws.#Config & {
|
||||||
|
region: *"us-east-1" | string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name of the S3 bucket to use
|
||||||
|
bucket: *"hello-s3.infralabs.io" | string
|
||||||
|
|
||||||
|
name: string | *"world"
|
||||||
|
|
||||||
|
page: """
|
||||||
|
<html>
|
||||||
|
</head>
|
||||||
|
<title>Simple static website on S3</title>
|
||||||
|
</head>
|
||||||
|
<h1>Hello!</h1>
|
||||||
|
<li>Hey \(name)</li>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
deploy: s3.#Put & {
|
||||||
|
config: awsConfig
|
||||||
|
sourceInline: page
|
||||||
|
contentType: "text/html"
|
||||||
|
target: "s3://\(bucket)/index.html"
|
||||||
|
}
|
Reference in New Issue
Block a user