add healthz, docker fixes, minor readme tweaks

This commit is contained in:
Nandor Magyar
2025-08-31 15:55:44 +02:00
committed by Levente Orban
parent cc8266ae6e
commit 94fffc5695
6 changed files with 41 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ POSTGRES_PASSWORD=cactoide_password
POSTGRES_PORT=5432
# localhost
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_database"
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoide_database"
# docker
# DATABASE_URL="postgres://cactoide:cactoide_password@postgres:5432/cactoied_database"

View File

@@ -20,4 +20,8 @@ EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/healthz || exit 1
CMD [ "node", "build" ]

View File

@@ -19,26 +19,26 @@ help:
# Build the Docker images
build:
@echo "Building Docker images..."
docker-compose build
docker compose build
# Start all services
up:
@echo "Starting all services..."
docker-compose up -d
docker compose up -d
# Start only the database
db-only:
@echo "Starting only the database..."
docker-compose up -d postgres
docker compose up -d postgres
# Show logs from all services
logs:
@echo "Showing logs from all services..."
docker-compose logs -f
docker compose logs -f
# Clean up everything (containers, images, volumes)
clean:
@echo "Cleaning up all Docker resources..."
docker-compose down -v --rmi all
docker compose down -v --rmi all

View File

@@ -27,10 +27,23 @@ A mobile-first event RSVP platform that lets you create events, share unique URL
### Quick Start
Requirements: git, docker, docker-compose
Uses the [`docker-compose.yml`](docker-compose.yml) file to setup the application with the database. You can define all ENV variables in the [`.env`](.env.example) file from the `.env.example`.
```bash
git clone https://github.com/polaroi8d/cactoide/
cd cactoide
cp env.example .env
docker compose up -d
```
### Development
Requirements: git, docker, docker-compose, node at least suggested 20.19.0
```bash
git clone https://github.com/polaroi8d/cactoide/
cd cactoide
npm install
cp env.example .env
make db-only
npm run dev -- --open
@@ -38,10 +51,6 @@ npm run dev -- --open
Your app will be available at `http://localhost:5173`. You can use the Makefile commands to run the application or the database, eg.: `make db-only`.
### Self-Host
Use the [`docker-compose.yml`](docker-compose.yml) file to setup the application with the database. You can define all ENV variables in the [`.env`](.env.example) file from the `.env.example`.
### License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

View File

@@ -1,5 +1,3 @@
version: '3.8'
services:
# Database
postgres:
@@ -29,6 +27,7 @@ services:
# Application
app:
image: ghcr.io/polaroi8d/cactoide/cactoide:${APP_VERSION:-latest}
build: .
container_name: cactoide-app
ports:
- '${PORT:-5111}:3000'

View File

@@ -0,0 +1,16 @@
// src/routes/healthz/+server.ts
import { json } from '@sveltejs/kit';
import { drizzleQuery } from '$lib/database/db';
import { sql } from 'drizzle-orm';
export async function GET() {
try {
await drizzleQuery.execute(sql`select 1`);
return json({ ok: true }, { headers: { 'cache-control': 'no-store' } });
} catch (err) {
return json(
{ ok: false, error: (err as Error)?.message ?? 'DB unavailable' },
{ status: 503, headers: { 'cache-control': 'no-store' } }
);
}
}