# DevOps

Infrastructure and deployment resources

by @traversymedia

Source: https://devstash.io/traversymedia/devops

## Docker Compose - Node.js + PostgreSQL

Production-ready Docker Compose setup for Node.js applications with PostgreSQL.

```yaml title="Docker Compose - Node.js + PostgreSQL"
version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/myapp
      - NODE_ENV=development
    volumes:
      - .:/app
      - /app/node_modules
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=myapp
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  postgres_data:
```

## Deploy to Production

Quick deployment script: pull latest changes, install deps, build, and restart PM2 processes.

```bash title="Deploy to Production"
git pull origin main && npm ci && npm run build && pm2 restart all
```

## Docker Documentation

Official Docker documentation - containers, images, compose, and more.

[Docker Documentation](https://docs.docker.com/)

## GitHub Actions Documentation

CI/CD workflows with GitHub Actions - automate builds, tests, and deployments

[GitHub Actions Documentation](https://docs.github.com/en/actions)
