From 4777117eebe0e9deecbb797f01061cf6ac3d1a1f Mon Sep 17 00:00:00 2001 From: Andre Kurait Date: Fri, 11 Oct 2024 16:40:39 -0500 Subject: [PATCH] Cleanup docker builds in cdk Signed-off-by: Andre Kurait --- .../service-stacks/capture-proxy-es-stack.ts | 2 +- .../lib/service-stacks/elasticsearch-stack.ts | 2 +- .../service-stacks/migration-service-core.ts | 21 ++----------------- .../reindex-from-snapshot-stack.ts | 2 +- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/deployment/cdk/opensearch-service-migration/lib/service-stacks/capture-proxy-es-stack.ts b/deployment/cdk/opensearch-service-migration/lib/service-stacks/capture-proxy-es-stack.ts index 532e312d0..d1eb9efa4 100644 --- a/deployment/cdk/opensearch-service-migration/lib/service-stacks/capture-proxy-es-stack.ts +++ b/deployment/cdk/opensearch-service-migration/lib/service-stacks/capture-proxy-es-stack.ts @@ -81,7 +81,7 @@ export class CaptureProxyESStack extends MigrationServiceCore { this.createService({ serviceName: "capture-proxy-es", - dockerDirectoryPath: join(__dirname, "../../../../../", "TrafficCapture/dockerSolution/build/docker/trafficCaptureProxyServer"), + dockerImageRegistryName: "migrations/capture_proxy_es:latest", dockerImageCommand: ['/bin/sh', '-c', command.concat(" & wait -n 1")], securityGroups: securityGroups, taskRolePolicies: servicePolicies, diff --git a/deployment/cdk/opensearch-service-migration/lib/service-stacks/elasticsearch-stack.ts b/deployment/cdk/opensearch-service-migration/lib/service-stacks/elasticsearch-stack.ts index a68f348d2..ca5a714a7 100644 --- a/deployment/cdk/opensearch-service-migration/lib/service-stacks/elasticsearch-stack.ts +++ b/deployment/cdk/opensearch-service-migration/lib/service-stacks/elasticsearch-stack.ts @@ -39,7 +39,7 @@ export class ElasticsearchStack extends MigrationServiceCore { this.createService({ serviceName: "elasticsearch", - dockerDirectoryPath: join(__dirname, "../../../../../", "TrafficCapture/dockerSolution/src/main/docker/elasticsearchWithSearchGuard"), + dockerImageRegistryName: "migrations/elasticsearch_searchguard:latest", securityGroups: securityGroups, portMappings: [servicePort], cpuArchitecture: props.fargateCpuArch, diff --git a/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-service-core.ts b/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-service-core.ts index da3744782..a0b3558c5 100644 --- a/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-service-core.ts +++ b/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-service-core.ts @@ -30,8 +30,7 @@ export interface MigrationServiceCoreProps extends StackPropsExt { readonly securityGroups: ISecurityGroup[], readonly cpuArchitecture: CpuArchitecture, readonly dockerFilePath?: string, - readonly dockerDirectoryPath?: string, - readonly dockerImageRegistryName?: string, + readonly dockerImageRegistryName: string, readonly dockerImageCommand?: string[], readonly dockerBuildArgs?: { [key: string]: string @@ -59,10 +58,6 @@ export class MigrationServiceCore extends Stack { serviceTaskRole: Role; createService(props: MigrationServiceCoreProps) { - if ((!props.dockerDirectoryPath && !props.dockerImageRegistryName) || (props.dockerDirectoryPath && props.dockerImageRegistryName)) { - throw new Error(`Exactly one option [dockerDirectoryPath, dockerImageRegistryName] is required to create the "${props.serviceName}" service`) - } - const ecsCluster = Cluster.fromClusterAttributes(this, 'ecsCluster', { clusterName: `migration-${props.stage}-ecs-cluster`, vpc: props.vpc @@ -86,19 +81,7 @@ export class MigrationServiceCore extends Stack { props.volumes.forEach(vol => serviceTaskDef.addVolume(vol)) } - let serviceImage - if (props.dockerDirectoryPath) { - serviceImage = ContainerImage.fromDockerImageAsset(new DockerImageAsset(this, "ServiceImage", { - directory: props.dockerDirectoryPath, - buildArgs: props.dockerBuildArgs, - // File path relative to above directory path - file: props.dockerFilePath - })) - } - else { - // @ts-ignore - serviceImage = ContainerImage.fromRegistry(props.dockerImageRegistryName) - } + let serviceImage = ContainerImage.fromRegistry(props.dockerImageRegistryName) const serviceLogGroup = new LogGroup(this, 'ServiceLogGroup', { retention: RetentionDays.ONE_MONTH, diff --git a/deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts b/deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts index 180f9e8a5..cc1ca43a9 100644 --- a/deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts +++ b/deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts @@ -167,7 +167,7 @@ export class ReindexFromSnapshotStack extends MigrationServiceCore { this.createService({ serviceName: 'reindex-from-snapshot', taskInstanceCount: 0, - dockerDirectoryPath: join(__dirname, "../../../../../", "DocumentsFromSnapshotMigration/docker"), + dockerImageRegistryName: "migrations/reindex-from-snapshot:latest", dockerImageCommand: ['/bin/sh', '-c', "/rfs-app/entrypoint.sh"], securityGroups: securityGroups, volumes: volumes,