Skip to content
Open
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ This repo shows how to deploy a Next.js app and a PostgreSQL database on a Ubunt

[![Self Hosting Video Thumbnail](https://img.youtube.com/vi/sIVL4JMqRfc/0.jpg)](https://www.youtube.com/watch?v=sIVL4JMqRfc)

## Push to ECR
If you only want to push it to ECR to run it in AppRunner, you can just use the `push_to_ecr.sh` script:
```sh
DB_USER=...
DB_PASSWORD=...
DB_HOST=...
DB_NAME=...

echo "DATABASE_URL=postgres://${DB_HOST}:${DB_PASSWORD}@${DB_HOST}:5432/${DB_NAME}" >> .env
./push_to_ecr.sh {ecr_registry} {ecr_repository}
```

## Prerequisites

1. Purchase a domain name
Expand Down
8 changes: 8 additions & 0 deletions app/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NextResponse } from 'next/server';

export async function GET() {
return new NextResponse('ok', {
status: 200,
headers: { 'Content-Type': 'text/plain' },
});
}
14 changes: 14 additions & 0 deletions push_to_ecr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

ECR_REGISTRY="$1"
ECR_REPOSITORY="$2"

if [ -z "$ECR_REGISTRY" ] || [ -z "$ECR_REPOSITORY" ]; then
echo "Usage: $0 <ECR_REGISTRY> <ECR_REPOSITORY>"
exit 1
fi

aws ecr get-login-password --region "us-west-2" | docker login --username AWS --password-stdin "$ECR_REGISTRY"

docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest