From 57366bbf2a32bd0dc6f1d0de408681b36a5501e3 Mon Sep 17 00:00:00 2001 From: Jorge Artave Date: Tue, 12 Aug 2025 08:37:37 -0300 Subject: [PATCH 1/2] Add health check --- app/health/route.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 app/health/route.ts diff --git a/app/health/route.ts b/app/health/route.ts new file mode 100644 index 0000000..3ae689e --- /dev/null +++ b/app/health/route.ts @@ -0,0 +1,8 @@ +import { NextResponse } from 'next/server'; + +export async function GET() { + return new NextResponse('ok', { + status: 200, + headers: { 'Content-Type': 'text/plain' }, + }); +} \ No newline at end of file From 94dcf36213565170ed9d6b71fdc5f8cab40eb506 Mon Sep 17 00:00:00 2001 From: Jorge Artave Date: Tue, 12 Aug 2025 08:37:48 -0300 Subject: [PATCH 2/2] Add helper to push to ecr --- README.md | 12 ++++++++++++ push_to_ecr.sh | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 push_to_ecr.sh diff --git a/README.md b/README.md index d71964a..64f96fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/push_to_ecr.sh b/push_to_ecr.sh new file mode 100755 index 0000000..abc2bec --- /dev/null +++ b/push_to_ecr.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +ECR_REGISTRY="$1" +ECR_REPOSITORY="$2" + +if [ -z "$ECR_REGISTRY" ] || [ -z "$ECR_REPOSITORY" ]; then + echo "Usage: $0 " + 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