mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 06:05:28 +00:00
add healthz, docker fixes, minor readme tweaks
This commit is contained in:
committed by
Levente Orban
parent
cc8266ae6e
commit
94fffc5695
@@ -5,7 +5,7 @@ POSTGRES_PASSWORD=cactoide_password
|
|||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
|
|
||||||
# localhost
|
# localhost
|
||||||
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_database"
|
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoide_database"
|
||||||
# docker
|
# docker
|
||||||
# DATABASE_URL="postgres://cactoide:cactoide_password@postgres:5432/cactoied_database"
|
# DATABASE_URL="postgres://cactoide:cactoide_password@postgres:5432/cactoied_database"
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,8 @@ EXPOSE 3000
|
|||||||
|
|
||||||
ENV PORT 3000
|
ENV PORT 3000
|
||||||
ENV HOSTNAME "0.0.0.0"
|
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" ]
|
CMD [ "node", "build" ]
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -19,26 +19,26 @@ help:
|
|||||||
# Build the Docker images
|
# Build the Docker images
|
||||||
build:
|
build:
|
||||||
@echo "Building Docker images..."
|
@echo "Building Docker images..."
|
||||||
docker-compose build
|
docker compose build
|
||||||
|
|
||||||
# Start all services
|
# Start all services
|
||||||
up:
|
up:
|
||||||
@echo "Starting all services..."
|
@echo "Starting all services..."
|
||||||
docker-compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
# Start only the database
|
# Start only the database
|
||||||
db-only:
|
db-only:
|
||||||
@echo "Starting only the database..."
|
@echo "Starting only the database..."
|
||||||
docker-compose up -d postgres
|
docker compose up -d postgres
|
||||||
|
|
||||||
# Show logs from all services
|
# Show logs from all services
|
||||||
logs:
|
logs:
|
||||||
@echo "Showing logs from all services..."
|
@echo "Showing logs from all services..."
|
||||||
docker-compose logs -f
|
docker compose logs -f
|
||||||
|
|
||||||
# Clean up everything (containers, images, volumes)
|
# Clean up everything (containers, images, volumes)
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning up all Docker resources..."
|
@echo "Cleaning up all Docker resources..."
|
||||||
docker-compose down -v --rmi all
|
docker compose down -v --rmi all
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -27,10 +27,23 @@ A mobile-first event RSVP platform that lets you create events, share unique URL
|
|||||||
|
|
||||||
### Quick Start
|
### 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
|
```bash
|
||||||
git clone https://github.com/polaroi8d/cactoide/
|
git clone https://github.com/polaroi8d/cactoide/
|
||||||
cd cactoide
|
cd cactoide
|
||||||
npm install
|
|
||||||
cp env.example .env
|
cp env.example .env
|
||||||
make db-only
|
make db-only
|
||||||
npm run dev -- --open
|
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`.
|
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
|
### License
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Database
|
# Database
|
||||||
postgres:
|
postgres:
|
||||||
@@ -29,6 +27,7 @@ services:
|
|||||||
# Application
|
# Application
|
||||||
app:
|
app:
|
||||||
image: ghcr.io/polaroi8d/cactoide/cactoide:${APP_VERSION:-latest}
|
image: ghcr.io/polaroi8d/cactoide/cactoide:${APP_VERSION:-latest}
|
||||||
|
build: .
|
||||||
container_name: cactoide-app
|
container_name: cactoide-app
|
||||||
ports:
|
ports:
|
||||||
- '${PORT:-5111}:3000'
|
- '${PORT:-5111}:3000'
|
||||||
|
|||||||
16
src/routes/healthz/+server.ts
Normal file
16
src/routes/healthz/+server.ts
Normal 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' } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user