This repository contains a Django application say_current_time
that is containerized using Docker. Follow the instructions below to clone the repository, navigate to the project directory, and run the project using Docker Compose.
Ensure you have the following installed on your system:
- Docker
- Docker Compose
- PostgreSQL (running in the same network
testnetwork
)
Clone the repository to your local machine using the following command:
git clone <repository-url>
Replace <repository-url>
with the actual URL of your GitHub repository.
Change your directory to the cloned repository:
cd django-app-dockerisation
The project directory contains the following structure:
django-app-dockerisation/
│
├── saycurrenttime/
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ ├── wsgi.py
│
├── Dockerfile
├── docker-compose.yaml
├── manage.py
├── README.md
├── requirements.txt
├── start.sh
└── .env
The environment variables required for the database configuration are stored in the .env
file. Ensure your .env
file contains the following variables:
db_engine=django.db.backends.postgresql
db_host=<your_db_host>
db_port=<your_db_port>
db_user=<your_db_user>
db_pass=<your_db_pass>
db_name=<your_db_name>
Replace <your_db_host>
, <your_db_port>
, <your_db_user>
, <your_db_pass>
, and <your_db_name>
with the actual values for your PostgreSQL database.
Use Docker Compose to build and run the project:
docker-compose up -d --build
This command will build the Docker image and start the containers in detached mode.
The application will be accessible at http://localhost:8000
.
To stop the application, use the following command:
docker-compose down
This will stop and remove the containers created by Docker Compose.