A Django app running inside Docker, configured with PostgreSQL and environment variables.
Run the following command to generate your own Django secret key:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
2. Create a .env file
In the root folder of the project, create a file named .env and add the following:
DJANGO_SECRET_KEY=your_generated_key_here
DEBUG=True
POSTGRES_DB=your_db
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
ALLOWED_HOSTS=localhost,127.0.0.1,web
DB_HOST=db
DB_PORT=5432
3. Build and Run with Docker
Build the Docker image:
docker-compose build
Start the server:
docker-compose up
4. Access the App
Once the containers are running, open your browser and go to:
http://localhost:8000/
http://127.0.0.1:8000/
The app should now be up and running ✅