From e7967ab3c135799c7060ded8aa353a18b2a79bec Mon Sep 17 00:00:00 2001 From: branberry Date: Fri, 23 Feb 2024 18:46:09 -0600 Subject: [PATCH] [DOP-4334]: Use cdk again --- .github/workflows/update-feature-branch.yml | 24 +++++++++---------- .../lib/constructs/worker/worker-construct.ts | 11 ++++++++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 0e30f44b5..4e558ba71 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -107,18 +107,18 @@ jobs: - 'cdk-infra/lib/constructs/worker/**' - 'Dockerfile' - 'modules/**' - - uses: docker/build-push-action@v5 - if: steps.filter.outputs.worker == 'true' - name: build Docker image - with: - context: . - tags: autobuilder/enhanced:latest - build-args: | - NPM_EMAIL=${{ secrets.NPM_EMAIL }} - NPM_BASE_64_AUTH=${{ secrets.NPM_BASE64_AUTH }} - cache-from: type=gha,ref=autobuilder/enhanced:latest - cache-to: type=gha,mode=max - outputs: type=tar,dest=cdk-infra/image.tar.gz + # - uses: docker/build-push-action@v5 + # if: steps.filter.outputs.worker == 'true' + # name: build Docker image + # with: + # context: . + # tags: autobuilder/enhanced:latest + # build-args: | + # NPM_EMAIL=${{ secrets.NPM_EMAIL }} + # NPM_BASE_64_AUTH=${{ secrets.NPM_BASE64_AUTH }} + # cache-from: type=gha,ref=autobuilder/enhanced:latest + # cache-to: type=gha,mode=max + # outputs: type=tar,dest=cdk-infra/image.tar.gz - name: Update Worker Stack if: steps.filter.outputs.worker == 'true' run: | diff --git a/cdk-infra/lib/constructs/worker/worker-construct.ts b/cdk-infra/lib/constructs/worker/worker-construct.ts index 0b355af09..f04c40d51 100644 --- a/cdk-infra/lib/constructs/worker/worker-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-construct.ts @@ -64,6 +64,15 @@ export class WorkerConstruct extends Construct { executionRole.addToPolicy(executionRoleSsmPolicy); + const containerProps: AssetImageProps = { + buildArgs: { + NPM_BASE_64_AUTH: dockerEnvironment.NPM_BASE_64_AUTH, + NPM_EMAIL: dockerEnvironment.NPM_EMAIL, + }, + cacheTo: { type: 'gha', params: { mode: 'max' } }, + cacheFrom: [{ type: 'gha' }], + }; + const taskDefLogGroup = new LogGroup(this, 'workerLogGroup'); const taskDefinition = new FargateTaskDefinition(this, 'workerTaskDefinition', { cpu: 4096, @@ -86,7 +95,7 @@ export class WorkerConstruct extends Construct { taskRole.addToPolicy(updateTaskProtectionPolicy); taskDefinition.addContainer('workerImage', { - image: ContainerImage.fromTarball(`${process.cwd()}/image.tar.gz`), + image: ContainerImage.fromAsset(path.join(__dirname, '../../../../'), containerProps), environment: dockerEnvironment, command: ['node', '--enable-source-maps', 'enhanced/enhancedApp.js'], logging: LogDrivers.awsLogs({