Sign inSign up

larify/portals-next

By larify

•Updated 2 months ago

Image
0

3.4K

larify/portals-next repository overview

⁠Portals Next - Docker Deployment Guide

A lightweight development proxy service for API debugging and testing. Route requests through proxy, cache, redirect, blob, and subscribe handlers.

⁠Quick Start

⁠Using Docker

1. Run database migration:

docker run --rm \
  -v ./data:/app/data \
  portals-next:migrate-latest

2. Start application:

docker run -d \
  -p 3000:3000 \
  -v ./data:/app/data \
  -e AUTH_SECRET="your-secret-key-here" \
  --name portals-next \
  portals-next
⁠Using Docker Compose
# Download docker-compose.yml and .env.example
curl -O https://raw.githubusercontent.com/your-repo/portals-next/main/docker-compose/deploy/docker-compose.yml
curl -O https://raw.githubusercontent.com/your-repo/portals-next/main/docker-compose/deploy/.env.example

# Configure environment
cp .env.example .env
# Edit .env and set AUTH_SECRET

# Start services (migration runs automatically)
docker-compose up -d

⁠Route Types

TypeShortcutDescription
proxypForward requests to target URL
redirectrHTTP redirects (301/302/307/308)
cachecCached proxy with Redis (requires Redis)
blobbServe stored text content
subscribesComposed subscription URLs

URL format: /<shortcut>/<pathname>

⁠Environment Variables

⁠Required
VariableDescriptionExample
AUTH_SECRETSecret key for authenticationGenerate with command below

Generate AUTH_SECRET:

openssl rand -base64 32
⁠Optional
VariableDescriptionDefault
NEXT_PUBLIC_BASE_PATHBase path for the application/
AUTH_TRUSTED_ORIGINSTrusted origins (comma-separated)*
⁠Redis (Optional - Only for Cache Routes)

Redis is only required if you plan to use cache routes. All other route types (proxy, redirect, blob, subscribe) work without Redis.

VariableDescriptionDefault
REDIS_HOSTRedis server hostname127.0.0.1
REDIS_PORTRedis server port6379
REDIS_PASSWORDRedis authentication password-
REDIS_DBRedis database number0

⁠Docker Deployment

⁠Build Images
# Build application image
docker build -t portals-next .

# Build migration image
docker build -f Dockerfile.migrate -t portals-next:migrate-latest .
⁠Database Migration

Run migration before starting the application:

docker run --rm \
  -v ./data:/app/data \
  portals-next:migrate-latest
⁠Run Container
docker run -d \
  -p 3000:3000 \
  -v ./data:/app/data \
  -e AUTH_SECRET="your-secret-key-here" \
  -e REDIS_HOST="redis-server" \
  -e REDIS_PORT="6379" \
  --name portals-next \
  portals-next
⁠With External Redis
docker run -d \
  -p 3000:3000 \
  -v ./data:/app/data \
  -e AUTH_SECRET="your-secret-key-here" \
  -e REDIS_HOST="your-redis-host" \
  -e REDIS_PORT="6379" \
  -e REDIS_PASSWORD="your-redis-password" \
  --name portals-next \
  portals-next

⁠Docker Compose Deployment

⁠Full Stack (App + Redis)

Create docker-compose.yml:

name: portals

services:
  redis:
    image: redis:7-alpine
    command: redis-server --save 60 1000 --appendonly yes
    volumes:
      - redis_data:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 5s
      timeout: 3s
      retries: 5
    restart: always
    networks:
      - portals-network

  migrate:
    image: portals-next:migrate-latest
    volumes:
      - './data:/app/data'
    restart: "no"
    networks:
      - portals-network

  portals:
    image: portals-next
    ports:
      - '${PORTALS_PORT:-3000}:3000'
    depends_on:
      redis:
        condition: service_healthy
      migrate:
        condition: service_completed_successfully
    volumes:
      - './data:/app/data'
    env_file:
      - .env
    restart: always
    networks:
      - portals-network

volumes:
  redis_data:
    driver: local

networks:
  portals-network:
    driver: bridge

Create .env:

AUTH_SECRET="your-secret-key-here"
REDIS_HOST="redis"
REDIS_PORT="6379"
PORTALS_PORT=3000

Start services:

docker-compose up -d

Manual migration:

docker-compose run --rm migrate
⁠App Only (External Redis)
services:
  portals:
    image: portals-next
    ports:
      - '3000:3000'
    volumes:
      - './data:/app/data'
    environment:
      - AUTH_SECRET=your-secret-key-here
      - REDIS_HOST=your-redis-host
      - REDIS_PORT=6379
      - REDIS_PASSWORD=your-redis-password
    restart: always

⁠Data Persistence

The application stores SQLite database in /app/data:

# Mount volume for data persistence
-v ./data:/app/data

⁠Kubernetes Deployment

⁠Using Init Container
apiVersion: apps/v1
kind: Deployment
metadata:
  name: portals-next
spec:
  template:
    spec:
      initContainers:
        - name: migrate
          image: ghcr.io/your-org/portals-next:migrate-latest
          volumeMounts:
            - name: data
              mountPath: /app/data
      containers:
        - name: app
          image: ghcr.io/your-org/portals-next:latest
          ports:
            - containerPort: 3000
          env:
            - name: AUTH_SECRET
              valueFrom:
                secretKeyRef:
                  name: portals-secrets
                  key: auth-secret
          volumeMounts:
            - name: data
              mountPath: /app/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: portals-data
⁠Using Job

For more control, use a separate Job for migration before deploying the application:

# Run migration job
kubectl create job portals-migrate --image=portals-next:migrate-latest
kubectl wait --for=condition=complete job/portals-migrate

# Deploy application
kubectl apply -f deployment.yaml

⁠First Run

  1. Visit http://localhost:3000
  2. Homepage is accessible without authentication
  3. Visit /sign-in to access admin dashboard
  4. If no admin account exists, you'll be redirected to /sign-up to create the first account

⁠Health Checks

# Liveness probe
curl http://localhost:3000/api/health/live

# Readiness probe
curl http://localhost:3000/api/health/ready

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:221b818f6…

Size

103.3 MB

Last updated

2 months ago

docker pull larify/portals-next