A reference full-stack application setup using Docker Compose to orchestrate frontend, backend, database, and other services. This repository contains Dockerfiles and Docker Compose configuration to make local development, testing, and simple deployments repeatable and isolated.
NOTE: This README is a template and intentionally generic so it fits different stacks (Node/React, Python/Flask, Ruby/Rails, etc.). Replace placeholder service names, commands, and environment variables with values from your project.
Table of contents
- Project overview
- Tech stack
- Prerequisites
- Quick start
- Development workflow
- Database & migrations
- Running tests
- Building images & production
- Environment variables
- Troubleshooting
- Project structure
This repository demonstrates how to run a full-stack application locally with Docker Compose. Services typically included:
- frontend (e.g., React, Vue, Angular)
- backend API (e.g., Node/Express, Python/Flask/Django, Ruby/Rails)
- database (e.g., PostgreSQL, MySQL)
- reverse proxy / local TLS (optional)
- worker/background job processor (optional)
The Docker Compose files define service relationships, networks, and volumes so you can bring the entire stack up with a single command.
- Docker & Docker Compose
- Frontend: (placeholder) — replace with your framework
- Backend: (placeholder) — replace with your framework
- Database: PostgreSQL (common), or replace with your choice
Update this section to match the actual stack in the repo.
- Docker (recommended: latest stable)
- Docker Compose (v2 recommended —
docker compose ...), ordocker-compose - git
- (Optional) make helper commands
Verify installation:
docker --version
docker compose version # or docker-compose --version- Clone the repo
git clone https://github.com/shubhmate/Setup-full-stack-app-with-Docker-Compose.git
cd Setup-full-stack-app-with-Docker-Compose- Copy and edit environment variables
cp .env.example .env
# edit .env to add secrets/credentials- Start services
docker compose up --build
# or to run in background:
docker compose up --build -d- Check logs
docker compose logs -f
# or per service:
docker compose logs -f backend- Stop and remove containers (keep volumes)
docker compose down- To remove volumes as well:
docker compose down -vIf you change the Dockerfile or the build context, rebuild images:
docker compose up --build --force-recreate -d- Edit frontend code locally; if the frontend service mounts the source directory into the container, hot-reload should work.
- Edit backend code locally; restart backend service if hot-reload is not configured.
- Use
docker compose exec <service> /bin/sh(or/bin/bash) to run commands inside a running container:
docker compose exec backend sh
# e.g., install deps, run migrations, run testsAdd convenient scripts or Makefile entries to simplify common tasks (start, stop, test, rebuild).
If your project uses a relational database:
- The database is configured in Docker Compose and persists to a named volume.
- Run migrations from the backend container:
docker compose exec backend sh -c "npm run migrate" # Node example
docker compose exec backend sh -c "python manage.py migrate" # Django exampleEnsure the backend service waits for the DB to be ready (use a wait-for script, healthchecks, or built-in retry logic).
Run tests in the container so they use the same environment as CI/dev:
docker compose exec backend sh -c "npm test"
# or
docker compose exec backend sh -c "pytest -q"You can create a CI profile in Docker Compose (e.g., docker-compose.ci.yml) that spins up minimal services for tests.
For production builds, create a production-oriented compose file (e.g., docker-compose.prod.yml) with optimized images, no bind mounts, and proper env secrets.
Build images locally:
docker compose -f docker-compose.prod.yml buildDeploy images to your registry (Docker Hub, GitHub Packages, etc.), and run on your host or orchestrator.
Create a .env file at the repo root (not committed with secrets). Example .env.example:
# .env.example
# Backend
BACKEND_PORT=8000
DATABASE_URL=postgres://user:password@db:5432/app_db
# Frontend
FRONTEND_PORT=3000
# Other
REDIS_URL=redis://redis:6379/0Replace placeholders with real values and secure secrets elsewhere (CI secrets/vaults/ GitHub Actions secrets).
- Port conflicts: make sure ports required by services are free or change them in
docker-compose.yml. - DB connection errors: check that DB credentials match and that the backend waits for DB readiness.
- Permission issues with volumes: ensure correct permissions on mounted directories.
- Use
docker compose psanddocker compose logs <service>to inspect failing services.
.
├── docker-compose.yml
├── docker-compose.prod.yml
├── backend/
│ ├── Dockerfile
│ └── ...
├── frontend/
│ ├── Dockerfile
│ └── ...
├── db/
│ └── init/
├── .env.example
└── README.md
Adjust to reflect the real layout of this repository.