Skip to content
Merged
Changes from 2 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
37 changes: 37 additions & 0 deletions webapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,40 @@ This project uses type-safe server actions with authentication:
);
}
```

### Asynchronous Jobs

Asynchronous jobs are Lambda functions that handle long-running or background tasks. The `job.Dockerfile` builds all TypeScript files in `src/jobs/` into separate Lambda handlers using `esbuild src/jobs/*.ts --bundle`.

**File structure:**

For simple jobs, place a single file directly under `src/jobs/`:

```
webapp/src/jobs/
├── migration-runner.ts # Single-file Lambda handler
└── async-job-runner.ts # Single-file Lambda handler
```

For jobs with complex logic, use a subdirectory:
Comment thread
konokenj marked this conversation as resolved.
Outdated

```
webapp/src/jobs/
├── async-job-runner.ts # Lambda handler entry point
└── async-job/ # Business logic directory
└── translate.ts # Job implementation
```

**Deployment:**

All jobs share the same `job.Dockerfile`. The CDK stack overrides the entry point using the `cmd` parameter in `DockerImageCode.fromImageAsset()`:

```typescript
// Example from cdk/lib/constructs/async-job.ts
code: DockerImageCode.fromImageAsset(join('..', 'webapp'), {
cmd: ['async-job-runner.handler'], // Override the default CMD
file: 'job.Dockerfile',
})
```

This allows multiple Lambda functions to use the same Docker image with different handlers.