GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing cookiecutter-django.readthedocs.io — Deployment with Docker — Cookiecutter Django 2026.49.4 documentation Deployment with DockerPrerequisites
Understanding the Docker Compose SetupBefore you begin, check out the
Provided you have opted for Celery (via setting
The Configuring the StackThe majority of services above are configured through the use of environment variables. Just check out Configuring the Environment and you will know the drill. If you generated the project with a cloud provider, the bucket holding your static files needs to allow public reads of the To obtain logs and information about crashes in a production setup, make sure that you have access to an external Sentry instance (e.g. by creating an account with sentry.io), and set the import logging logging.error("This event is sent to Sentry", extra={"<example_key>": "<example_value>"}) The extra parameter allows you to send additional information about the context of this error. You will probably also need to setup the Mail backend, for example by adding a Mailgun API key and a Mailgun sender domain, otherwise, the account creation view will crash and result in a 500 error when the backend attempts to send an email to the account owner. Warning If your email server used to send email isn’t configured properly (Mailgun by default), attempting to send an email will cause an Internal Server Error. By default, This may happen just after you’ve setup your Mailgun account, which is running in a sandbox subdomain by default. Either add your email to the list of authorized recipients or verify your domain. Optional: Use AWS IAM Role for EC2 instanceIf you are deploying to AWS, you can use the IAM role to substitute AWS credentials, after which it’s safe to remove the HTTPS is On by DefaultSSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client, typically in this case, a web server (website) and a browser. Not having HTTPS means that malicious network users can sniff authentication credentials between your website and end users’ browser. It is always better to deploy a site behind HTTPS and will become crucial as the web services extend to the IoT (Internet of Things). For this reason, we have set up a number of security defaults to help make your website secure:
The Traefik reverse proxy used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically. All you need to do to enable this is to make sure that your DNS records are pointing to the server Traefik runs on. You can read more about this feature and how to configure it, at Automatic HTTPS in the Traefik docs. (Optional) Postgres Data Volume ModificationsPostgres is saving its database files to the Building & Running Production StackYou will need to build the stack first. To do that, run: docker compose -f docker-compose.production.yml build Once this is ready, you can run it with: docker compose -f docker-compose.production.yml up To run the stack and detach the containers, run: docker compose -f docker-compose.production.yml up -d To run a migration, open up a second terminal and run: docker compose -f docker-compose.production.yml run --rm django python manage.py migrate To create a superuser, run: docker compose -f docker-compose.production.yml run --rm django python manage.py createsuperuser If you need a shell, run: docker compose -f docker-compose.production.yml run --rm django python manage.py shell To check the logs out, run: docker compose -f docker-compose.production.yml logs If you want to scale your application, run: docker compose -f docker-compose.production.yml up --scale django=4 docker compose -f docker-compose.production.yml up --scale celeryworker=2 Warning don’t try to scale To see how your containers are doing run: docker compose -f docker-compose.production.yml ps Example: SupervisorOnce you are ready with your initial setup, you want to make sure that your application is run by a process manager to
survive reboots and auto restarts in case of an error. You can use the process manager you are most familiar with. All
it needs to do is to run If you are using [program:{{cookiecutter.project_slug}}] command=docker compose -f docker-compose.production.yml up directory=/path/to/{{cookiecutter.project_slug}} redirect_stderr=true autostart=true autorestart=true priority=10 Move it to supervisorctl reread supervisorctl update supervisorctl start {{cookiecutter.project_slug}} For status check, run: supervisorctl status Media files without cloud providerIf you chose no cloud provider and Docker, the media files will be served by an nginx service, from a |
| You are visitor 01402860 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |