mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 14:15:28 +00:00
feat: add analytics to website and small improvements
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
# Docker Configuration
|
||||
# Postgres configuration
|
||||
POSTGRES_DB=cactoied_database
|
||||
POSTGRES_USER=cactoide
|
||||
POSTGRES_PASSWORD=cactoide_password
|
||||
POSTGRES_PORT=5432
|
||||
|
||||
# Development Settings
|
||||
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_database"
|
||||
|
||||
# Application configuration
|
||||
APP_VERSION=latest
|
||||
ANALYTICS=true
|
||||
PORT=3000
|
||||
HOSTNAME=0.0.0.0
|
||||
NODE_ENV=production
|
||||
1
.github/workflows/build-and-push.yml
vendored
1
.github/workflows/build-and-push.yml
vendored
@@ -3,6 +3,7 @@ name: build & push the images
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['*']
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
|
||||
18
README.md
18
README.md
@@ -25,15 +25,7 @@ A mobile-first event RSVP platform that lets you create events, share unique URL
|
||||
- **🛡️ Smart Limits** - Choose between unlimited RSVPs or set a limited capacity. Perfect for any event size.
|
||||
- **✨ Effortless Simplicity** - Designed to be instantly clear and easy. No learning curve — just open, create, and go.
|
||||
|
||||
### 🏗️ Technology
|
||||
|
||||
- **SvelteKit** - Full-stack web framework
|
||||
- **Tailwind CSS** - Utility-first CSS framework
|
||||
- **TypeScript** - Type-safe development
|
||||
- **PostgreSQL** - Robust relational database
|
||||
- **Drizzle ORM** - Type-safe database queries
|
||||
|
||||
### 🚀 Quick Start
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
git clone https://github.com/polaroi8d/cactoide/
|
||||
@@ -44,13 +36,13 @@ make db-only
|
||||
npm run dev -- --open
|
||||
```
|
||||
|
||||
Your app will be available at `http://localhost:5173`
|
||||
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
|
||||
### Self-Host
|
||||
|
||||
WIP
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Database
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: cactoide-db-prod
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-cactoied_database}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-cactoide}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cactoide_password}
|
||||
ports:
|
||||
- '5432:5432'
|
||||
volumes:
|
||||
- postgres_data_prod:/var/lib/postgresql/data
|
||||
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
'CMD-SHELL',
|
||||
'pg_isready -U ${POSTGRES_USER:-cactoide} -d ${POSTGRES_DB:-cactoied_database}'
|
||||
]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- cactoide-network-prod
|
||||
restart: unless-stopped
|
||||
|
||||
# Application
|
||||
app:
|
||||
image: ghcr.io/polaroi8d/cactoide:latest
|
||||
container_name: cactoide-app-prod
|
||||
ports:
|
||||
- '3000:3000'
|
||||
environment:
|
||||
DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:5432/${POSTGRES_DB:-cactoied_database}
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
HOSTNAME: 0.0.0.0
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- cactoide-network-prod
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
postgres_data_prod:
|
||||
|
||||
networks:
|
||||
cactoide-network-prod:
|
||||
driver: bridge
|
||||
@@ -1,38 +1,42 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# PostgreSQL Database
|
||||
# Database
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: cactoide-db
|
||||
environment:
|
||||
POSTGRES_DB: cactoied_database
|
||||
POSTGRES_USER: cactoide
|
||||
POSTGRES_PASSWORD: cactoide_password
|
||||
POSTGRES_DB: ${POSTGRES_DB:-cactoied_database}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-cactoide}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cactoide_password}
|
||||
ports:
|
||||
- '5432:5432'
|
||||
- '${POSTGRES_PORT:-5432}:5432'
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U cactoide -d cactoied_database']
|
||||
test:
|
||||
[
|
||||
'CMD-SHELL',
|
||||
'pg_isready -U ${POSTGRES_USER:-cactoide} -d ${POSTGRES_DB:-cactoied_database}'
|
||||
]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- cactoide-network
|
||||
|
||||
# SvelteKit Application
|
||||
# Application
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: ghcr.io/polaroi8d/cactoide/cactoide:${APP_VERSION:-latest}
|
||||
container_name: cactoide-app
|
||||
ports:
|
||||
- '3000:3000'
|
||||
- '${PORT:-3000}:3000'
|
||||
environment:
|
||||
DATABASE_URL: postgres://cactoide:cactoide_password@postgres:5432/cactoied_database
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-cactoied_database}
|
||||
NODE_ENV: ${NODE_ENV:-dev}
|
||||
PORT: 3000
|
||||
HOSTNAME: ${HOSTNAME:-0.0.0.0}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Production Environment Variables
|
||||
# Copy this file to .env.prod and update the values
|
||||
|
||||
# Database Configuration
|
||||
POSTGRES_DB=cactoide_production
|
||||
POSTGRES_USER=cactoide_prod
|
||||
POSTGRES_PASSWORD=your_secure_password_here
|
||||
|
||||
# App Configuration
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
%sveltekit.head%
|
||||
%sveltekit.head% %ANALYTICS_SCRIPT%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
|
||||
27
src/hooks.server.ts
Normal file
27
src/hooks.server.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
export const handle = async ({ event, resolve }) => {
|
||||
// Check if analytics is enabled
|
||||
const analyticsEnabled = env.ANALYTICS === 'true';
|
||||
|
||||
// Define the analytics script HTML
|
||||
const analyticsScript = analyticsEnabled
|
||||
? '<script defer src="https://analytics.dalev.hu/script.js" data-website-id="7425d098-e340-4464-bd03-c2e47b004cd9"></script>'
|
||||
: '';
|
||||
|
||||
// Replace the placeholder with the actual script or empty string
|
||||
const response = await resolve(event);
|
||||
|
||||
if (response.headers.get('content-type')?.includes('text/html')) {
|
||||
const html = await response.text();
|
||||
const modifiedHtml = html.replace('%ANALYTICS_SCRIPT%', analyticsScript);
|
||||
|
||||
return new Response(modifiedHtml, {
|
||||
headers: response.headers,
|
||||
status: response.status,
|
||||
statusText: response.statusText
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
Reference in New Issue
Block a user