Skip to content

Add Docker local development environment#1

Open
WilliamsJason wants to merge 3 commits intopnwinsects:masterfrom
WilliamsJason:docker-local-dev-pr
Open

Add Docker local development environment#1
WilliamsJason wants to merge 3 commits intopnwinsects:masterfrom
WilliamsJason:docker-local-dev-pr

Conversation

@WilliamsJason
Copy link
Copy Markdown

Summary

Adds a Docker-based local development setup so developers can run the site with a single command.

What's included

  • Dockerfile — Python 2.7 container with all dependencies, Django admin template fixes
  • docker-compose.yml — One-command startup with persistent SQLite database
  • docker-entrypoint.sh — Auto-initializes database (South migrations) on first run
  • requirements-docker.txt — Docker-compatible deps (Pillow instead of PIL, no MySQL/Xapian)
  • settings_docker.py — SQLite, dummy search, CSRF disabled for local dev, login bypassed
  • urls_docker.py — Static/media file serving for Django dev server

Quick start

docker-compose up --build
# Then one-time: docker-compose exec web python manage.py createsuperuser
# Browse to http://localhost:8000

WilliamsJason and others added 3 commits March 21, 2026 11:24
- Dockerfile using python:2.7 with all dependencies
- docker-compose.yml for one-command startup
- SQLite database (no MySQL needed locally)
- Auto-initializing entrypoint script (syncdb + migrate)
- Stub modules for unavailable packages (admin_sentry, csvimporter, csv_admin)
- Static/media file serving via urls_docker.py
- Login requirement exempted for local browsing

Usage:
  docker-compose up --build
  docker-compose exec web python manage.py createsuperuser

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Switch from SQLite to MySQL 5.6 container matching production server
- Add mysqlclient to requirements, default-libmysqlclient-dev to Dockerfile
- docker-compose.yml now starts MySQL service with auto-import from data/
- Entrypoint waits for MySQL readiness, detects pre-loaded SQL dump
- Settings use environment variables for DB config (DB_HOST, DB_NAME, etc.)
- Add data/ to .gitignore (SQL dumps are large, not committed)
- Include zzz-local-fixes.sql to fix CMS page permissions for local dev

Place stripped SQL dump in data/pnwmoths-local.sql, then:
  docker-compose up --build

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@rainhead rainhead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this going! I tried it as far as seeing that docker compose up was successful.

Comment thread Dockerfile
Comment on lines +1 to +12
FROM python:2.7

# Fix apt sources — Debian Stretch is archived
RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list && \
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list && \
sed -i '/stretch-updates/d' /etc/apt/sources.list 2>/dev/null; \
apt-get update && apt-get install -y --no-install-recommends \
libjpeg-dev \
zlib1g-dev \
libfreetype6-dev \
default-libmysqlclient-dev \
&& rm -rf /var/lib/apt/lists/*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu:22.04 supports Python2.7 and gets security updates. Would that work better?

Comment thread docker-compose.yml
@@ -0,0 +1,49 @@
services:
db:
image: mysql:5.6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this requires platform: linux/amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants