Repository navigation
Expand file tree
/
Copy pathmain.cue
More file actions
96 lines (82 loc) · 2.18 KB
/
Copy pathmain.cue
File metadata and controls
96 lines (82 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"b.l/bl"
"stackbrew.io/file"
"stackbrew.io/aws"
"stackbrew.io/aws/s3"
"stackbrew.io/aws/ecr"
)
input: {
awsAccessKey: bl.Secret
awsSecretKey: bl.Secret
}
config: {
// Generate a new directory from the HTML code
htmlSource: file.Create & {
filename: "index.html"
contents: """
<html>
<head><title>Hello World!</title></head>
<body><h1>Yoo</h1></body>
</html>
"""
}
// Build a new docker container from the html source above
dockerImage: bl.Build & {
context: htmlSource.result
dockerfile: """
FROM nginx
COPY . /usr/share/nginx/html
"""
}
imageTarget: "125635003186.dkr.ecr.us-east-2.amazonaws.com/docs-demo:nginx-static"
awsCreds: {
accessKey: input.awsAccessKey
secretKey: input.awsSecretKey
}
// Login to AWS ECR
ecrCredentials: ecr.Credentials & {
config: aws.Config & {
region: "us-east-2"
awsCreds
}
target: imageTarget
}
// Push the docker image to AWS ECR
imagePush: bl.Push & {
source: dockerImage.image
target: imageTarget
credentials: ecrCredentials.credentials
}
// Deploy the static index.html to S3
deployS3: s3.Put & {
config: aws.Config & {
region: "us-west-2"
awsCreds
}
source: htmlSource.result
target: "s3://hello-s3.infralabs.io/"
}
// Deploy resulted image to ECS
deployECS: SimpleAppECS & {
infra: awsConfig: awsCreds
app: {
hostname: "hello-ecs.infralabs.io"
containerImage: imagePush.ref
}
}
// Deploy resulted image to Kubernetes EKS
deployEKS: SimpleAppEKS & {
infra: awsConfig: awsCreds
app: {
hostname: "hello-kube.infralabs.io"
containerImage: imagePush.ref
}
}
}
output: {
urlS3: "http://hello-s3.infralabs.io/"
urlEKS: "https://\(config.deployEKS.app.hostname)/"
urlECS: "https://\(config.deployECS.app.hostname)/"
imageRef: config.imagePush.ref
}