Skip to content

campagnollo/golden_hex_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golden_hex_docker

A Docker‑based deployment for a Django web application served behind Nginx, designed for simple, repeatable deployment on a single Linux host (such as an AWS EC2 instance).

This repository demonstrates a clean separation of concerns:

  • Django runs as an application container
  • Nginx runs as a reverse proxy container
  • Docker Compose orchestrates the stack

The setup is intentionally minimal and well‑suited for infrastructure‑as‑code workflows using tools like Ansible.


Architecture Overview

Client
  │
  ▼
Nginx (container)
  │  reverse proxy
  ▼
Django (container)
  • Nginx listens on ports 80/443 and proxies traffic to Django
  • Django runs the application server (e.g., Gunicorn)
  • Both services run on the same Docker network

Repository Structure

.
├── docker-compose.yaml
├── dockerfile_django
├── dockerfile_nginx
├── default.conf
├── requirements.txt
├── manage.py
├── <django_project_files>
└── README.md

Key Files

  • docker-compose.yaml – Defines and orchestrates the Django and Nginx services
  • dockerfile_django – Builds the Django application image
  • dockerfile_nginx – Builds the Nginx reverse proxy image
  • default.conf – Nginx site configuration
  • requirements.txt – Python dependencies for Django

Prerequisites

On the target host:

  • Linux (Ubuntu or Amazon Linux recommended)
  • Docker
  • Docker Compose v2 (docker compose)

Verify installation:

docker --version
docker compose version

Environment Variables

Create a .env file in the project root (not committed to git):

DJANGO_SECRET_KEY=your-secret-key
DJANGO_DEBUG=false
DJANGO_ALLOWED_HOSTS=*

Additional variables (database, email, etc.) can be added as needed.


Build and Run

From the project root:

docker compose up -d --build

This will:

  1. Build the Django image
  2. Build the Nginx image
  3. Start both containers in detached mode

Check running containers:

docker compose ps

View logs:

docker compose logs -f

Application Access

Once running:

  • Application is accessible via http:///
  • Nginx proxies requests to the Django container

Stopping the Stack

docker compose down

Deployment Notes

AWS EC2

This project works well on a single EC2 instance. Typical flow:

  1. Provision EC2
  2. Install Docker and Compose
  3. Clone this repository
  4. Create .env
  5. Run docker compose up -d

Automation with Ansible

This repository is designed to be easily automated:

  • Ansible installs Docker and dependencies
  • Ansible checks out this repo
  • Ansible templates .env and Nginx config
  • Ansible runs docker compose up -d

This allows repeatable, idempotent deployments.


Production Considerations

For more robust environments, consider:

  • Building images in CI and pulling from a registry (ECR/Docker Hub)
  • Using AWS SSM Parameter Store or Ansible Vault for secrets
  • Adding HTTPS via Let’s Encrypt or an ALB
  • Using multiple instances behind a load balancer for zero downtime

Goals of This Repository

  • Demonstrate clean Docker‑based service separation
  • Provide a foundation for infrastructure‑as‑code workflows
  • Keep the setup understandable and extensible

License

This project is provided as‑is for learning and experimentation.

About

a docker-compose setup for the golden hex website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors