Skip to content

Conversation

@AleJimenezRJ
Copy link
Contributor

This pull request introduces several improvements to the Docker-based development and production setup for the Django project. The main focus is on simplifying environment variable management, improving the reliability of migrations and superuser creation, and updating dependencies for better security and compatibility.

Key changes include:

Docker and Environment Configuration

  • Removed .env.local.example and all references to .env.local in Docker Compose files to simplify environment variable management and reduce confusion between environments. Now only .env, .env.dev, and .env.prod are used.
  • Updated the default Python version in the Dockerfile from 3.12-slim to 3.14-slim for better performance and support.
  • Upgraded PostGIS and Redis images in production to postgis/postgis:16-3.4 and redis:8-alpine respectively for improved security and features.

Database and Redis Handling

  • Improved DATABASE_URL construction logic in docker-entrypoint.sh to handle cases where the database password may be missing, avoiding malformed URLs.
  • Added explicit REDIS_HOST and REDIS_PORT settings to .env.prod and Docker Compose files for consistency.

Migrations and Superuser Management

  • Added RUN_MAKEMIGRATIONS and MIGRATE_ON_CELERY environment variables to control when migrations and makemigrations are run, reducing the risk of race conditions and unnecessary migration attempts. By default, makemigrations is disabled except when explicitly enabled.
  • Refined the logic for running migrations in Celery services to prevent concurrent migrations, and added a check to ensure django_celery_beat tables exist before starting the beat process.
  • Improved superuser creation: now controlled by CREATE_SUPERUSER (default enabled in development), using environment variables for username, password, and email, and using the standard createsuperuser command for better compatibility.

Miscellaneous

  • Updated healthchecks for the database service to check the correct database name and user.
  • Changed the initial data fixture loaded on startup from bucr.json to gtfs.json, reflecting updated project requirements.
  • Minor improvements to scripts, including more engaging output in dev.sh and color tweaks in prod.sh.

These changes should make local and production setups more robust, predictable, and easier to maintain.

fabianabarca and others added 3 commits November 5, 2025 16:10
Improve migration, superuser, and beat readiness logic

Disables automatic migrations for Celery by default to prevent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants