-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOP-4170]: Create AWS ECS Task definition to process Snooty Parser c…
…ache updates (#951) * [DOP-4170]: Create lambda and Dockerfile for custom environment * [DOP-4170]: Create stack to deploy cache updater * [DOP-4170]: Update lambda dockerfile * [DOP-4170]: Update workflow * [DOP-4170]: Fix typo * [DOP-4170]: Increase timeout * [DOP-4170]: Use arm 💪 * [DOP-4170]: Use arm 💪 * [DOP-4170]: Use arm64 💪 * [DOP-4170]: Use arm64 💪 * [DOP-4170]: Format names correctly * [DOP-4170]: Revert arch * [DOP-4170]: Log event * [DOP-4170]: Add git * [DOP-4170]: Clone repo and run cache build * [DOP-4170]: Refactor pipeline a bit * [DOP-4170]: Add credentials * [DOP-4170]: Refactor each step into a separate function for simplicity * [DOP-4170]: Refactor each step into a separate function for simplicity * [DOP-4170]: Clone to tmp directory * [DOP-4170]: Update dependencies * [DOP-4170]: Add S3 and uploadCache starting code * [DOP-4170]: Small changes * [DOP-4170]: Add s3 upload library * [DOP-4170]: Add cache upload * [DOP-4170]: Add try catch * [DOP-4170]: Update snooty parser version * [DOP-4170]: Reorder no caching flag * [DOP-4170]: Use latest snooty parser version * [DOP-4170]: Refactor caching * [DOP-4170]: Use debugging snooty branch * [DOP-4170]: Use worker instead of lambda * [DOP-4170]: Add fargate task def and custer * [DOP-4170]: Refactor cache updater to be used for ecs task * [DOP-4170]: Clean up * [DOP-4170]: Clean up * [DOP-4170]: Move cache updater to src directory and add logic to build caches for multiple sites * [DOP-4170]: Add readme and refactor cdk constructs * [DOP-4170]: Add VPC for cache updater stack * [DOP-4170]: Üse correct path * [DOP-4170]: Üse correct path * [DOP-4170]: Update cpu architecture * [DOP-4170]: Add QEMU * [DOP-4170]: Add Snooty parser version * [DOP-4170]: Don't use arm * [DOP-4170]: use buildkit action * [DOP-4170]: Remove buildkit setup * [DOP-4170]: don't use slim * [DOP-4170]: Add log group and update workflow conditions * [DOP-4170]: Add echo statements * [DOP-4170]: Add echo statements * [DOP-4170]: Add echo statements * [DOP-4170]: Update filter to include base * [DOP-4170]: Update filter to only look at previous commit * [DOP-4170]: Revert and figure out later * [DOP-4170]: Grant task permission to write to S3 * [DOP-4170]: Add readmes * [DOP-4170]: Add throw statements * [DOP-4170]: PR feedback * [DOP-4170]: Undo to check if build passes now * [DOP-4170]: Add import back in * [DOP-4170]: Remove cross project imports * [DOP-4170]: Update environment * [DOP-4170]: Remove api from dockerfile * [DOP-4170]: Remove unused imports
- Loading branch information
Showing
10 changed files
with
4,094 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Docs Worker Pool Workflows | ||
|
||
This README describes the various workflows defined for the docs-worker-pool repository. | ||
|
||
## Feature Branch Deploys | ||
|
||
The feature branch deploy process occurs whenever a developer opens a pull request. It consists of three separate workflows: | ||
|
||
1. `deploy-feature-branch.yml` - Creates the initial infrastructure when a PR is opened, this includes draft PRs | ||
2. `update-feature-branch.yml` - Ran whenever a commit is made to the branch for the PR, and conditionally deploys each stack depending on changes made | ||
3. `clean-feature-branch.yml` - Ran whenever a PR is merged or closed; deletes all of the infrastructure for the feature branch | ||
|
||
### Bugs | ||
|
||
Right now, there is a small bug with the `update-feature-branch.yml` workflow. This workflow conditionally deploys the various stacks depending on what files have changed from a commit. The issue is that the custom filter action compares the PR branch to master for every workflow run. This means that if you make a change to `src/app.ts` in the first commit, but only make changes to files in the `api/` directory in subsequent commits, it will still run the deploy for the worker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
cdk-infra/lib/constructs/cache-updater/cache-updater-worker-construct.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { IVpc } from 'aws-cdk-lib/aws-ec2'; | ||
import { Cluster, ContainerImage, FargateTaskDefinition, LogDrivers } from 'aws-cdk-lib/aws-ecs'; | ||
import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; | ||
import { LogGroup } from 'aws-cdk-lib/aws-logs'; | ||
import { Bucket } from 'aws-cdk-lib/aws-s3'; | ||
import { Construct } from 'constructs'; | ||
import path from 'path'; | ||
|
||
const SNOOTY_CACHE_BUCKET_NAME = 'snooty-parse-cache'; | ||
|
||
interface CacheUpdaterWorkerConstructProps { | ||
vpc: IVpc; | ||
} | ||
|
||
export class CacheUpdaterWorkerConstruct extends Construct { | ||
clusterName: string; | ||
|
||
constructor(scope: Construct, id: string, { vpc }: CacheUpdaterWorkerConstructProps) { | ||
super(scope, id); | ||
|
||
const cluster = new Cluster(this, 'cacheUpdaterCluster', { | ||
vpc, | ||
}); | ||
|
||
const taskRole = new Role(this, 'cacheUpdateWorkerTaskRole', { | ||
assumedBy: new ServicePrincipal('ecs-tasks.amazonaws.com'), | ||
}); | ||
|
||
const snootyParseCacheBucket = Bucket.fromBucketName(this, SNOOTY_CACHE_BUCKET_NAME, SNOOTY_CACHE_BUCKET_NAME); | ||
|
||
snootyParseCacheBucket.grantWrite(taskRole); | ||
|
||
const taskDefinition = new FargateTaskDefinition(this, 'cacheUpdaterWorker', { | ||
cpu: 2048, | ||
memoryLimitMiB: 4096, | ||
taskRole, | ||
}); | ||
|
||
const taskDefLogGroup = new LogGroup(this, 'cacheUpdaterWorkerLogGroup'); | ||
|
||
taskDefinition.addContainer('cacheUpdaterWorkerImage', { | ||
image: ContainerImage.fromAsset(path.join(__dirname, '../../../../'), { | ||
file: 'src/cache-updater/Dockerfile.cacheUpdater', | ||
buildArgs: { SNOOTY_PARSER_VERSION: '0.15.2' }, | ||
exclude: ['tests/', 'node_modules/', 'cdk-infra/'], // adding this just in case it doesn't pick up our dockerignore | ||
}), | ||
environment: { | ||
SNOOTY_CACHE_BUCKET_NAME, | ||
}, | ||
logging: LogDrivers.awsLogs({ | ||
streamPrefix: 'cacheupdater', | ||
logGroup: taskDefLogGroup, | ||
}), | ||
}); | ||
|
||
this.clusterName = cluster.clusterName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Stack } from 'aws-cdk-lib'; | ||
import { Construct } from 'constructs'; | ||
import { CacheUpdaterWorkerConstruct } from '../constructs/cache-updater/cache-updater-worker-construct'; | ||
import { IVpc } from 'aws-cdk-lib/aws-ec2'; | ||
|
||
interface CacheUpdaterStackProps { | ||
vpc: IVpc; | ||
} | ||
export class CacheUpdaterStack extends Stack { | ||
constructor(scope: Construct, id: string, { vpc }: CacheUpdaterStackProps) { | ||
super(scope, id); | ||
|
||
new CacheUpdaterWorkerConstruct(this, 'cache-updater-resources', { vpc }); | ||
} | ||
} |
Oops, something went wrong.