mirror of https://github.com/docker/compose.git
Create CloudMap private namespace and register services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9a6fe86a86
commit
0eab586106
|
@ -2,7 +2,7 @@ clean:
|
|||
rm -rf dist/
|
||||
|
||||
build:
|
||||
go build -v -o dist/docker-ecs cmd/main.go
|
||||
go build -v -o dist/docker-ecs cmd/main/main.go
|
||||
|
||||
test: ## Run tests
|
||||
go test ./... -v
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/awslabs/goformation/v4/cloudformation/ec2"
|
||||
"github.com/awslabs/goformation/v4/cloudformation/ecs"
|
||||
"github.com/awslabs/goformation/v4/cloudformation/iam"
|
||||
cloudmap "github.com/awslabs/goformation/v4/cloudformation/servicediscovery"
|
||||
"github.com/docker/ecs-plugin/pkg/compose"
|
||||
)
|
||||
|
||||
|
@ -54,6 +55,13 @@ func (c client) Convert(ctx context.Context, project *compose.Project) (*cloudfo
|
|||
LogGroupName: logGroup,
|
||||
}
|
||||
|
||||
// Private DNS namespace will allow DNS name for the services to be <service>.<project>.local
|
||||
template.Resources["CloudMap"] = &cloudmap.PrivateDnsNamespace{
|
||||
Description: fmt.Sprintf("Service Map for Docker Compose project %s", project.Name),
|
||||
Name: fmt.Sprintf("%s.local", project.Name),
|
||||
Vpc: vpc,
|
||||
}
|
||||
|
||||
for _, service := range project.Services {
|
||||
definition, err := Convert(project, service)
|
||||
if err != nil {
|
||||
|
@ -89,6 +97,19 @@ func (c client) Convert(ctx context.Context, project *compose.Project) (*cloudfo
|
|||
ServiceName: service.Name,
|
||||
TaskDefinition: cloudformation.Ref(taskDefinition),
|
||||
}
|
||||
|
||||
var healthCheck *cloudmap.Service_HealthCheckConfig
|
||||
if service.HealthCheck != nil && !service.HealthCheck.Disable {
|
||||
// FIXME ECS only support HTTP(s) health checks, while Docker only support CMD
|
||||
}
|
||||
|
||||
serviceRegistration := fmt.Sprintf("%sServiceRegistration", service.Name)
|
||||
template.Resources[serviceRegistration] = &cloudmap.Service{
|
||||
Description: fmt.Sprintf("%q registration in Service Map", service.Name),
|
||||
HealthCheckConfig: healthCheck,
|
||||
Name: serviceRegistration,
|
||||
NamespaceId: cloudformation.Ref("CloudMap"),
|
||||
}
|
||||
}
|
||||
return template, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue