Merge pull request #444 from samalba/s3-example
examples/simple-s3: easier example to understand simple use case
This commit is contained in:
commit
d93a1d24b8
@ -25,20 +25,22 @@ dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
|
|||||||
dagger input text awsConfig.secretKey MY_AWS_SECRET_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
|
```sh
|
||||||
dagger up
|
dagger up
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Change a variable to alter the content
|
5. Check the URL
|
||||||
|
|
||||||
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
|
```sh
|
||||||
dagger input text name "someone else!"
|
curl -i $(dagger query url -f text)
|
||||||
dagger up
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deploy a simple React application
|
## Deploy a simple React application
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"dagger.io/aws"
|
"dagger.io/aws"
|
||||||
"dagger.io/aws/s3"
|
"dagger.io/aws/s3"
|
||||||
|
"dagger.io/dagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AWS Config for credentials and default region
|
// AWS Config for credentials and default region
|
||||||
@ -11,24 +12,14 @@ awsConfig: aws.#Config & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name of the S3 bucket to use
|
// Name of the S3 bucket to use
|
||||||
bucket: *"hello-s3.infralabs.io" | string
|
bucket: *"dagger-io-examples" | string
|
||||||
|
|
||||||
name: string | *"world"
|
source: dagger.#Artifact
|
||||||
|
url: "\(deploy.url)index.html"
|
||||||
page: """
|
|
||||||
<html>
|
|
||||||
</head>
|
|
||||||
<title>Simple static website on S3</title>
|
|
||||||
</head>
|
|
||||||
<h1>Hello!</h1>
|
|
||||||
<li>Hey \(name)</li>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
deploy: s3.#Put & {
|
deploy: s3.#Put & {
|
||||||
config: awsConfig
|
config: awsConfig
|
||||||
sourceInline: page
|
"source": source
|
||||||
always: true
|
contentType: "text/html"
|
||||||
contentType: "text/html"
|
target: "s3://\(bucket)/"
|
||||||
target: "s3://\(bucket)/index.html"
|
|
||||||
}
|
}
|
||||||
|
9
examples/simple-s3/website/index.html
Normal file
9
examples/simple-s3/website/index.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<html>
|
||||||
|
</head>
|
||||||
|
<title>My Simple Website</title>
|
||||||
|
</head>
|
||||||
|
<h1>Shopping list</h1>
|
||||||
|
<li>Salad</li>
|
||||||
|
<li>Eggs</li>
|
||||||
|
<li>Potatoes</li>
|
||||||
|
</html>
|
Reference in New Issue
Block a user