Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce task startup time for embedding job #185

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/embedding.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ WORKDIR /src
COPY ./embedding.requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt --no-cache-dir

RUN playwright install
RUN playwright install chromium

COPY ./embedding ./embedding
COPY ./app ./app

ENTRYPOINT [ "python3" ]
CMD ["-u", "embedding/main.py"]
CMD ["-u", "embedding/main.py"]
7 changes: 7 additions & 0 deletions cdk/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 80
}
18 changes: 10 additions & 8 deletions cdk/lib/constructs/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Construct } from "constructs";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as path from "path";
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
import { DockerImageAsset, Platform } from "aws-cdk-lib/aws-ecr-assets";
import * as iam from "aws-cdk-lib/aws-iam";
import { ITable } from "aws-cdk-lib/aws-dynamodb";
import { CfnPipe } from "aws-cdk-lib/aws-pipes";
Expand All @@ -16,6 +16,7 @@ import {
IFunction,
} from "aws-cdk-lib/aws-lambda";
import { DynamoEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import { SociIndexBuild } from "deploy-time-build";

export interface DbConfig {
readonly host: string;
Expand Down Expand Up @@ -76,14 +77,15 @@ export class Embedding extends Construct {
retention: logs.RetentionDays.ONE_WEEK,
});

const asset = new DockerImageAsset(this, "Image", {
directory: path.join(__dirname, "../../../backend"),
file: "embedding.Dockerfile",
platform: Platform.LINUX_AMD64,
});
SociIndexBuild.fromDockerImageAsset(this, "Index", asset);

const container = taskDefinition.addContainer("Container", {
image: ecs.ContainerImage.fromAsset(
path.join(__dirname, "../../../backend"),
{
file: "embedding.Dockerfile",
platform: Platform.LINUX_AMD64,
}
),
image: ecs.AssetImage.fromDockerImageAsset(asset),
logging: ecs.LogDriver.awsLogs({
streamPrefix: "embed-task",
logGroup: taskLogGroup,
Expand Down
7 changes: 4 additions & 3 deletions cdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading