Deployment

Docker Deployment

Deploy to your own server using Docker.

Introduction

Docker deployment provides:

  • Consistent environments
  • Easy scaling
  • Simple management
  • Isolated services

Prerequisites

  • Docker installed
  • Docker Compose installed
  • Domain name configured
  • SSL certificates ready

Dockerfile

Basic Dockerfile configuration:

# Build stage
FROM node:20-alpine AS builder

WORKDIR /app
COPY . .

RUN npm install
RUN npm run build

# Production stage
FROM node:20-alpine

WORKDIR /app
COPY --from=builder /app/.output .

ENV HOST=0.0.0.0
ENV PORT=3000
EXPOSE 3000

CMD ["node", "server/index.mjs"]

Docker Compose

docker-compose.yml configuration:

version: "3"
services:
  web:
    build: .
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=postgresql://user:pass@db:5432/mydb
    depends_on:
      - db

  db:
    image: postgres:14
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
      - POSTGRES_DB=mydb
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Deployment Steps

  1. Build the image:
docker-compose build
  1. Start services:
docker-compose up -d
  1. Check logs:
docker-compose logs -f
  1. Stop services:
docker-compose down

Environment Variables

Remember to set up your .env file with production values:

NODE_ENV=production
DATABASE_URL=postgresql://user:pass@db:5432/mydb
NUXT_PUBLIC_SITE_URL=https://your-domain.com

Monitoring

Monitor your containers using:

docker stats

Or use tools like:

  • Portainer
  • Docker Dashboard
  • Prometheus + Grafana

Backup

Regular backup of:

  • Database volumes
  • Uploaded files
  • Configuration files

Security

  • Use official base images
  • Keep images updated
  • Scan for vulnerabilities
  • Follow security best practices

end


Resources

Features

Company

Copyright © 2025. All rights reserved.