Deployment

Deploy with Docker

Deploy your scanlation website using Docker containers for easy management and scalability.

Prerequisites

  • Docker installed on your server
  • Docker Compose (v2.0+)
  • Domain name (optional but recommended)
  • SSL certificate (optional, can use Let's Encrypt)

Docker Compose Configuration

The template includes a production-ready docker-compose.yml:

version: '3.8'

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=mongodb://mongo:27017/scanlation
    depends_on:
      - mongo
      - minio
    restart: unless-stopped

  mongo:
    image: mongo:7
    volumes:
      - mongo_data:/data/db
    restart: unless-stopped

  minio:
    image: minio/minio
    command: server /data --console-address ":9001"
    volumes:
      - minio_data:/data
    environment:
      - MINIO_ROOT_USER=minioadmin
      - MINIO_ROOT_PASSWORD=minioadmin
    ports:
      - "9000:9000"
      - "9001:9001"
    restart: unless-stopped

volumes:
  mongo_data:
  minio_data:

Deployment Steps

  1. 1

    Clone the repository

    git clone https://github.com/YOUR_USERNAME/scanlation-template.git
  2. 2

    Configure environment variables

    cp .env.example .env.production nano .env.production
  3. 3

    Build and start containers

    docker compose up -d --build
  4. 4

    Run database migrations

    docker compose exec app pnpm db:migrate
  5. 5

    Seed initial data (optional)

    docker compose exec app pnpm db:seed

Dockerfile

The included Dockerfile uses multi-stage builds for optimal image size:

FROM node:20-alpine AS base

# Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile

# Build the app
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable && pnpm build

# Production image
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]

Useful Commands

docker compose up -dStart all services in background
docker compose downStop all services
docker compose logs -f appView app logs
docker compose restart appRestart the app
docker compose pullPull latest images
docker compose exec app shAccess app container shell

Nginx Reverse Proxy (Optional)

For production, use Nginx as a reverse proxy with SSL:

server {
    listen 80;
    server_name yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}