Skip to content

Commit

Permalink
ynr/settings: add containerised local.py example
Browse files Browse the repository at this point in the history
  • Loading branch information
jpluscplusm committed Jan 9, 2025
1 parent de5e27e commit f39e792
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ynr/settings/local.py.container.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Only set DEBUG to True in development environments.
DEBUG = True

# This short, known value is insecure.
SECRET_KEY = "development"

# Certain errors are very noisy (obscuring the real problem) if this list is
# empty.
ADMINS = [("Dummy Admin", "[email protected]")]

# This permits the site to be served at localhost:8080.
ALLOWED_HOSTS = ['*']

# This unpleasantness adds the container's internal IP to the list of those IPs
# permitted to access the Django debug toolbar, which allows it to be enabled.
# We believe the container's own IP needs to be in this list because of
# something to do with the container networking, or the HTTP server gunicorn's
# reverse-proxy setup, or both.
# TODO: Replace with a better method, either here or by changing the
# container/gunicorn setup. https://pypi.org/project/netifaces/ also exists,
# but might not be considered "better".
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
INTERNAL_IPS = [ '127.0.0.1', str(s.getsockname()[0]) ]
s.close()

0 comments on commit f39e792

Please sign in to comment.