Orange Country Lettings Journal

Deployment Process


Deploying the Django project to production required several key steps to ensure stability, performance, and a streamlined workflow. Below is a breakdown of the process:

1. Environment Variables

Instead of using a .env file, I utilized PyCharm’s project settings to configure DJANGO_SETTINGS_MODULE directly for each environment. This allowed for flexible management of settings based on development or production needs:

      • Local Settings: For each environment, I set DJANGO_SETTINGS_MODULE to the relevant settings file within PyCharm. The local settings file contains all necessary environment variables for easy configuration.
      • Configuration Files:
        • settings.py
        • settings-template-local.py
        • settings-ci.py

2. Installing and Configuring Gunicorn and WhiteNoise

To transition the project to production:

      • Gunicorn: Installed as a Python WSGI HTTP server, Gunicorn facilitates communication between Django and incoming HTTP requests. It’s essential for handling production traffic.
      • WhiteNoise: WhiteNoise was added to manage static file handling, compressing and caching files for improved load times and performance in production.

3. Creating the Docker Image

Building a Docker image encapsulates the application environment, enabling consistent deployments across various machines. For detailed steps on Docker configuration, refer to the Docker setup section.

4. Setting Up CI/CD with GitHub Actions

I implemented a CI/CD pipeline via GitHub Actions, which ensures that all code is checked, tested, and automatically deployed when pushed to the main branch.

5. Configuring Docker Hub Webhook on Render

To automate deployment, I linked Docker Hub with Render using a webhook. This setup allows Render to automatically pull the latest Docker image upon updates.

6. Creating the deploy.sh File

Instead of embedding all commands directly in the Dockerfile, I created a separate deploy.sh script. This allowed me to manage permissions independently and streamline the deployment process:

      • Permissions: Before pushing to GitHub, I adjusted Linux file permissions to ensure proper execution.
      • The script handles all necessary deployment steps, making it reusable and easy to maintain.


Designed by BootstrapMade and modified by DoriDoro