Skip to content

Add Docker and docker-compose for local development #15

Description

@prodbycorne

Overview

Developers currently need to install Redis manually and manage environment variables by hand. A docker-compose.yml will let anyone run the full local stack with a single command.

docker-compose Services

services:
  api:
    build: .
    ports:
      - "4000:4000"
    environment:
      - REDIS_URL=redis://redis:6379
      - DATABASE_URL=postgres://smartdrop:smartdrop@postgres:5432/smartdrop
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
    volumes:
      - ./src:/app/src   # hot reload in dev

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: smartdrop
      POSTGRES_PASSWORD: smartdrop
      POSTGRES_DB: smartdrop
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "smartdrop"]
      interval: 5s

Dockerfile

Multi-stage build:

  1. builder stage: npm ci --omit=dev
  2. production stage: copy node_modules + src from builder

Requirements

  • Dockerfile at repo root for production builds
  • docker-compose.yml for local dev (includes hot reload)
  • docker-compose.override.yml gitignored for local secrets
  • .dockerignore to exclude node_modules, .env, tests
  • README section: Quick Start (docker compose up)

Acceptance Criteria

  • docker compose up starts all services and API responds on port 4000
  • API auto-restarts on src/ file change in dev mode
  • .env.example variables work with docker-compose defaults
  • .dockerignore present and excludes sensitive files
  • README updated with Quick Start section
  • Production image < 200 MB

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaigninfrastructureDevOps, CI/CD, Docker, deployment

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions