Skip to content

Commit

Permalink
Create deploy tool for deploying AWS Lambda Docker containers (#731)
Browse files Browse the repository at this point in the history
Shorthand tool for:

1. Logging into ECR
2. Building the Docker image
3. Pushing the Docker image to ECR
4. Updating the lambda code with the image

## Usage

From the root directory, invoke Ship and specify which app to deploy. It
will read the ship.json config file in the target directory.

```sh
pnpm ship deploy apps/dispatcher-auth --env dev
```

Example ship.json configuration

```json
{
  "imageName": "dispatcher-auth",
  "version": "latest",
  "environments": [
    {
      "name": "dev",
      "ecrRepository": "891459268445.dkr.ecr.eu-north-1.amazonaws.com/dispatcher-auth-dev",
      "functionName": "dispatcher-auth-dev",
      "dockerfile": "apps/dispatcher-auth/Dockerfile"
    }
  ]
}
```
  • Loading branch information
junlarsen authored Nov 21, 2023
1 parent 20fcdff commit b089c20
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 200 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
.next
.turbo
.react-email
.git

.dockerignore
.env*

node_modules
infra
Expand Down
3 changes: 0 additions & 3 deletions apps/dispatcher-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"build": "tsup src/lambda.ts && echo '{\"type\":\"module\"}' > dist/package.json",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint --fix .",
"docker:build": "docker build --platform linux/amd64 -t dispatcher-auth:latest -f Dockerfile ../..",
"docker:push:dev": "docker tag dispatcher-auth:latest 891459268445.dkr.ecr.eu-north-1.amazonaws.com/dispatcher-auth-dev:latest && docker push 891459268445.dkr.ecr.eu-north-1.amazonaws.com/dispatcher-auth-dev:latest",
"lambda:update:dev": "aws lambda update-function-code --function-name dispatcher-auth-dev --image-uri 891459268445.dkr.ecr.eu-north-1.amazonaws.com/dispatcher-auth-dev:latest",
"type-check": "tsc --noEmit"
},
"dependencies": {
Expand Down
12 changes: 12 additions & 0 deletions apps/dispatcher-auth/ship.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"imageName": "dispatcher-auth",
"version": "latest",
"environments": [
{
"name": "dev",
"ecrRepository": "891459268445.dkr.ecr.eu-north-1.amazonaws.com/dispatcher-auth-dev",
"functionName": "dispatcher-auth-dev",
"dockerfile": "apps/dispatcher-auth/Dockerfile"
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"type-check": "turbo run type-check",
"clean": "turbo run clean",
"docker:login": "aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 891459268445.dkr.ecr.eu-north-1.amazonaws.com",
"docker:login:public": "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws"
"docker:login:public": "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws",
"ship": "pnpm --filter=@dotkomonline/ship ship"
},
"workspaces": [
"packages/*",
Expand Down
3 changes: 1 addition & 2 deletions packages/logger/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import winston, { format } from "winston"
import { env } from "@dotkomonline/env"
export type { Logger } from "winston"

export const getLogger = (path: string) =>
winston.createLogger({
level: "info",
silent: env.NODE_ENV === "test",
silent: process.env.NODE_ENV === "test",
format: format.json(),
transports: [
new winston.transports.Console({
Expand Down
Loading

0 comments on commit b089c20

Please sign in to comment.