live Link: http://82.112.227.13:8008/
This guide will walk you through setting up and running a Django application using ASGI (Asynchronous Server Gateway Interface) both locally and with Docker Compose.
Before getting started, make sure you have the following installed:
- Python (3.10 recommended)
- Docker
- Docker Compose
Clone this repository to your local machine:
git clone https://github.com/potentialInc/django_boilerplate.git
cd dir_nameCreate and activate a virtual environment to isolate your project dependencies:
python3 -m venv env
source env/bin/activate # On Unix or MacOS
# OR
env\Scripts\activate # On WindowsInstall the required Python dependencies using pip:
pip install -r requirements.txtRun the Django application using the ASGI server:
python manage.py runserverBuild the Docker image using the provided Dockerfile:
docker build -t django-asgi-app .Run the Docker container based on the built image(Manually):
docker run -p 8000:8000 django-asgi-appUse Docker Compose to manage your application services. First, create a new file named docker-compose.yml if it
doesn't exist already, and then run the following command:
docker-compose up -d Once the services are up and running, you can access your Django application at http://localhost:8000.
To deploy your Django application using Docker Compose, follow these steps:
-
Prepare your server environment with Docker and Docker Compose installed.
-
Copy your project files to the server.
-
Modify the
docker-compose-example.ymlfile as needed (e.g., update environment variables, ports). -
Use
docker-composeto start your application services on the server:docker-compose -f up -d
-
Ensure that your server's firewall allows traffic on the specified ports.
-
You can now access your deployed application using the server's IP address or domain name.