|
@@ -26,7 +26,7 @@ import (
|
|
|
"strings"
|
|
"strings"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- "github.com/aws/aws-sdk-go/aws"
|
|
|
|
|
|
|
+ "github.com/docker/compose-cli/ecs/secrets"
|
|
|
|
|
|
|
|
ecsapi "github.com/aws/aws-sdk-go/service/ecs"
|
|
ecsapi "github.com/aws/aws-sdk-go/service/ecs"
|
|
|
"github.com/awslabs/goformation/v4/cloudformation"
|
|
"github.com/awslabs/goformation/v4/cloudformation"
|
|
@@ -34,13 +34,12 @@ import (
|
|
|
"github.com/compose-spec/compose-go/types"
|
|
"github.com/compose-spec/compose-go/types"
|
|
|
"github.com/docker/cli/opts"
|
|
"github.com/docker/cli/opts"
|
|
|
"github.com/joho/godotenv"
|
|
"github.com/joho/godotenv"
|
|
|
-
|
|
|
|
|
- "github.com/docker/compose-cli/ecs/secrets"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const secretsInitContainerImage = "docker/ecs-secrets-sidecar"
|
|
const secretsInitContainerImage = "docker/ecs-secrets-sidecar"
|
|
|
|
|
+const searchDomainInitContainerImage = "docker/ecs-searchdomain-sidecar"
|
|
|
|
|
|
|
|
-func (b *ecsAPIService) createTaskExecution(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefinition, error) {
|
|
|
|
|
|
|
+func (b *ecsAPIService) createTaskDefinition(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefinition, error) {
|
|
|
cpu, mem, err := toLimits(service)
|
|
cpu, mem, err := toLimits(service)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
@@ -48,15 +47,6 @@ func (b *ecsAPIService) createTaskExecution(project *types.Project, service type
|
|
|
_, memReservation := toContainerReservation(service)
|
|
_, memReservation := toContainerReservation(service)
|
|
|
credential := getRepoCredentials(service)
|
|
credential := getRepoCredentials(service)
|
|
|
|
|
|
|
|
- // override resolve.conf search directive to also search <project>.local
|
|
|
|
|
- // TODO remove once ECS support hostname-only service discovery
|
|
|
|
|
- service.Environment["LOCALDOMAIN"] = aws.String(
|
|
|
|
|
- cloudformation.Join("", []string{
|
|
|
|
|
- cloudformation.Ref("AWS::Region"),
|
|
|
|
|
- ".compute.internal",
|
|
|
|
|
- fmt.Sprintf(" %s.local", project.Name),
|
|
|
|
|
- }))
|
|
|
|
|
-
|
|
|
|
|
logConfiguration := getLogConfiguration(service, project)
|
|
logConfiguration := getLogConfiguration(service, project)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -74,6 +64,14 @@ func (b *ecsAPIService) createTaskExecution(project *types.Project, service type
|
|
|
mounts = append(mounts, secretsMount)
|
|
mounts = append(mounts, secretsMount)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ initContainers = append(initContainers, ecs.TaskDefinition_ContainerDefinition{
|
|
|
|
|
+ Name: fmt.Sprintf("%s_ResolvConf_InitContainer", normalizeResourceName(service.Name)),
|
|
|
|
|
+ Image: searchDomainInitContainerImage,
|
|
|
|
|
+ Essential: false,
|
|
|
|
|
+ Command: []string{b.Region + ".compute.internal", project.Name + ".local"},
|
|
|
|
|
+ LogConfiguration: logConfiguration,
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
var dependencies []ecs.TaskDefinition_ContainerDependency
|
|
var dependencies []ecs.TaskDefinition_ContainerDependency
|
|
|
for _, c := range initContainers {
|
|
for _, c := range initContainers {
|
|
|
dependencies = append(dependencies, ecs.TaskDefinition_ContainerDependency{
|
|
dependencies = append(dependencies, ecs.TaskDefinition_ContainerDependency{
|