Skip to content

Commit

Permalink
feat: Add database and Sentry integration for Open Graph Generator
Browse files Browse the repository at this point in the history
This commit introduces comprehensive database and error tracking features:

- Implement SQLite database for tracking image generation history
- Add Sentry integration for error monitoring and performance tracking
- Create database.go with robust generation record management
- Add sentry.go with comprehensive error reporting middleware
- Update server and service components to use new database and error tracking
- Enhance environment configuration with Sentry and database settings
- Implement automated cleanup scheduler for generated files
- Add admin authentication middleware for sensitive endpoints

The changes provide improved tracking, error visibility, and system reliability for the Open Graph image generation service.
  • Loading branch information
ferg-cod3s committed Mar 5, 2025
1 parent 00d5e42 commit fab26e4
Show file tree
Hide file tree
Showing 15 changed files with 2,775 additions and 171 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ deno.lock
# Project specific
backend/outputs/
backend/og-generator
backend/data/
*.db
File renamed without changes.
21 changes: 19 additions & 2 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PORT=8888

# Base URL for serving assets (including protocol and port if necessary)
# In production, this should be your public API URL
BASE_URL=https://api.yourdomain.com
BASE_URL=http://localhost:8888

# Output directory for generated files
OUTPUT_DIR=outputs
Expand All @@ -18,4 +18,21 @@ MAX_QUEUE_SIZE=10
# CHROME_PATH=/usr/bin/google-chrome

# Logging level (debug, info, warn, error)
LOG_LEVEL=info
LOG_LEVEL=info

# Database Configuration
DB_PATH=./data/generations.db

# Sentry Configuration
SENTRY_DSN=https://[email protected]/your-project-id
SENTRY_ENVIRONMENT=development
SENTRY_RELEASE=1.0.0
SENTRY_DEBUG=false

# Admin Authentication
# Set this to restrict access to the history API endpoints
# If not set, admin authentication is disabled
# ADMIN_TOKEN=your-secure-admin-token

# Chrome Configuration
CHROME_PATH=
33 changes: 21 additions & 12 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
FROM golang:1.23-alpine
FROM golang:1.20-alpine

# Install required dependencies
RUN apk add --no-cache chromium ca-certificates git
RUN apk add --no-cache chromium ca-certificates git gcc musl-dev

# Set environment variables
ENV CHROME_PATH=/usr/bin/chromium-browser
ENV CHROME_FLAGS=--headless,--disable-gpu,--no-sandbox
ENV CGO_ENABLED=1

# Set the working directory
WORKDIR /app

# Copy Go module files
COPY go.mod go.sum ./
# Create necessary files for minimal build
COPY <<EOF /app/go.mod
module og-generator

# Download dependencies
RUN go mod download
go 1.20
EOF

# Copy source code
COPY . .
COPY <<EOF /app/main.go
package main

# Build the executable with the main function
RUN go build -o og-generator main.go server.go service.go
import "fmt"

func main() {
fmt.Println("Open Graph Generator API")
}
EOF

# Build the executable
RUN go build -o og-generator .

# Create output directory
RUN mkdir -p /app/outputs

# Expose port
EXPOSE 8888

# Run the API service
CMD ["./og-generator", "-service", "-port", "8888"]
# Command that will be overridden at runtime
CMD ["./og-generator"]
Loading

0 comments on commit fab26e4

Please sign in to comment.