This is a Dockerized Django application for managing an e-commerce system with PostgreSQL as the database and PgAdmin for database management.
Before starting, ensure you have the following installed on your machine:
git clone https://github.com/kalyanakannan/ecommerce.git
cd ecommerce
Create a .env
file in the root directory with the following environment variables:
# Django settings
DJANGO_DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
# Database settings
DATABASE_NAME=ecommerce_db
DATABASE_USER=ecommerce_user
DATABASE_PASSWORD=secure_password
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
# pgAdmin settings
PGADMIN_DEFAULT_EMAIL=[email protected]
PGADMIN_DEFAULT_PASSWORD=admin
To build and start the application, use:
docker-compose up --build
This will:
- Build the
app
service from the providedDockerfile
. - Start the
PostgreSQL
andPgAdmin
services. - Apply migrations and start the Django application using Gunicorn.
The application will be available at http://localhost:8000
.
PgAdmin will be available at http://localhost:5050
. Use the email and password specified in the .env
file to log in.
To run tests, enter the app
container and execute the test suite:
docker exec -it app_container python manage.py test
docker-compose down
To view logs for the app container:
docker logs app_container
If you make changes to the Dockerfile
or dependencies:
docker-compose down --volumes
docker-compose up --build
- Ensure
ALLOWED_HOSTS
in the.env
file includeslocalhost
or*
for development.
- Verify the
DATABASE_*
environment variables in the.env
file match the settings indocker-compose.yml
. - Check the
postgres_container
logs for errors:docker logs postgres_container