Skip to content

Custom manage.py Entry Point Script#265

Merged
lemonsaurus merged 7 commits into
masterfrom
new-managepy
Sep 29, 2019
Merged

Custom manage.py Entry Point Script#265
lemonsaurus merged 7 commits into
masterfrom
new-managepy

Conversation

@scragly
Copy link
Copy Markdown
Contributor

@scragly scragly commented Sep 27, 2019

I've done up a custom manage.py to suit a few custom purposes and to help aid a simplified development setup.

The SiteManager will handle preparing the server for both development and production environments, ensuring appropriate preparations are only run on the correct environments.

Development Environment

manage.py run --debug

Preparation steps

  1. DEBUG env var added
  2. Wait until PostgreSQL database is accepting connections
  3. A super user is created for website with admin:admin as default.
    • User can set custom super user details with env vars:
      • SUPER_USERNAME
      • SUPER_PASSWORD
  4. Run migrate
  5. Run collectstatic
  6. Run the Django development server on port 8000.

Fixes

  • Avoid migrate and collectstatic running twice on first launch due to development web server StatReloader.

Production Environment

manage.py run

Preparation steps

  1. Run migrate
  2. Run collectstatic
  3. Run the uwsgi production server.

Dockerfile & Compose

  • manage.py is the entry point now for Dockerfile as almost any Django command would need to be run through it.
  • bot docker will connect to the same project stack, so will use the internal docker domain web to reference the container on the network. Aliases have been added for relevant subdomains and the new domain aliases added to ALLOWED_HOSTS when in debug mode.

File Changes

  • Dockerfile and local.Dockerfile were no longer distinct, so both environments use the one file.
  • docker/apps directory is now the docker directory.

Comment thread manage.py
Comment thread manage.py
Comment thread manage.py Outdated
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

This looks excellent, my only comments are what @MarkKoz already caught and you fixed already.

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