Skip to content

Add Docker Compose setup for local development #14

@2214962083

Description

@2214962083

Summary

Setting up a local development environment for a Cloudflare Workers project can be confusing for new contributors. A Docker Compose setup would provide a one-command development environment, lowering the barrier to contribution significantly.

Problem

New contributors need to:

  1. Install Node.js with the correct version
  2. Install and configure Wrangler
  3. Set up local D1 databases and KV namespaces
  4. Understand the Cloudflare Workers local dev workflow

This is a lot of steps, and any one of them can go wrong. A Docker Compose setup would eliminate most of these friction points.

Expected Behavior / Deliverable

  • A docker-compose.yml (or compose.yml) file at the project root.
  • A Dockerfile.dev for the development environment.
  • Running docker compose up should:
    • Install all dependencies
    • Start the Wrangler dev server with local D1/KV emulation
    • Expose the app on a predictable port (e.g., localhost:8787)
    • Support hot-reload when source files change (volume mount)
  • A CONTRIBUTING.md or updated README.md section documenting:
    • Prerequisites (Docker + Docker Compose)
    • How to start the dev environment
    • How to run tests inside the container
    • Common troubleshooting tips

Implementation Hints

  • Project root contains package.json and wrangler.toml (or wrangler.jsonc) — these define the Worker configuration.
  • Wrangler supports local development via wrangler dev --local which emulates D1/KV/R2 locally using Miniflare.
  • The Dockerfile should be based on a Node.js image and run npm install + npx wrangler dev.
  • Use volume mounts for src/ so changes are reflected without rebuilding.
  • Environment variables can be passed via docker-compose.yml or a .env.example file.

Acceptance Criteria

  • docker-compose.yml and Dockerfile.dev added to project root
  • docker compose up starts a working dev environment
  • Hot-reload works for source file changes
  • Documentation added (CONTRIBUTING.md or README section)
  • .env.example file with required environment variables documented

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions