-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
87 lines (84 loc) · 2.67 KB
/
build.sbt
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
import Dependencies._
import sbt.Keys._
import jp.pigumer.sbt.cloud.aws.cloudformation._
import jp.pigumer.sbt.cloud.aws.ecr.AwsecrCommands
val Region = "ap-northeast-1"
val BucketName = sys.env.get("BUCKET_NAME") // YOUR BUCKET NAME
val awsecrPush = taskKey[Unit]("Push")
lazy val root = (project in file("."))
.enablePlugins(CloudformationPlugin, JavaAppPackaging, AshScriptPlugin, DockerPlugin)
.settings(
organization := "com.pigumer",
name := "http",
version := "0.0.1-SNAPSHOT",
scalaVersion := "2.12.6",
libraryDependencies ++= Seq(
akkaHttp,
akkaStream
)
).settings(
dockerBaseImage := "openjdk:8-jre-alpine",
dockerExposedPorts := Seq(8080, 9010),
mainClass in assembly := Some("com.pigumer.http.HelloWorld")
).settings(
awscfSettings := AwscfSettings(
region = Region,
bucketName = BucketName,
templates = Some(file("cloudformation"))
)
).settings(
awscfStacks := Stacks(
Alias("iam") → CloudformationStack(
stackName = "aws-ecs-iam",
template = "iam.yaml",
capabilities = Seq("CAPABILITY_NAMED_IAM")
),
Alias("codebuild") → CloudformationStack(
stackName = "aws-ecs-codebuild",
template = "codebuild.yaml",
parameters = Map(
"Location" → BucketName.get
)
),
Alias("vpc") → CloudformationStack(
stackName = "aws-ecs-vpc",
template = "vpc.yaml"
),
Alias("alb") → CloudformationStack(
stackName = "aws-ecs-alb",
template = "alb.yaml"
),
Alias("ecr") → CloudformationStack(
stackName = "aws-ecs-ecr",
template = "ecr.yaml"
),
Alias("ecscluster") → CloudformationStack(
stackName = "aws-ecs-ecscluster",
template = "ecscluster.yaml"
),
Alias("ec2") → CloudformationStack(
stackName = "aws-ecs-ec2",
template = "ec2.yaml",
parameters = Map(
"ImageId" → "ami-f3f8098c"
),
capabilities = Seq("CAPABILITY_IAM")
),
Alias("http") → CloudformationStack(
stackName = "aws-ecs-http",
template = "http.yaml",
parameters = Map(
"Image" → s"${(awsecrDomain in awsecr).value}/http:${version.value}"
),
capabilities = Seq("CAPABILITY_IAM")
)
)
).settings(
awsecrPush := {
val docker = (awsecrDockerPath in awsecr).value
val source = s"${packageName.value}:${version.value}"
val target = s"${(awsecrDomain in awsecr).value}/${awscfGetValue.toTask(" ECR").value}:${version.value}"
AwsecrCommands.tag(docker, source, target)
AwsecrCommands.push(docker, target)
}
)