Skip to content

Commit

Permalink
Cleanup docker builds in cdk
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <akurait@amazon.com>
  • Loading branch information
AndreKurait committed Oct 11, 2024
1 parent e304aa1 commit 4777117
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4777117

Please sign in to comment.