Baby Tools Shop
The Baby Tools Shop is a web application developed using Django. This repository contains all the necessary files to build and run the application in a Docker container. The main purpose of this repository is to provide an easy setup and deployment process for a basic e-commerce platform focusing on baby products.
Table of Contents
Quickstart
Prerequisites
- Docker
- Git
Installation and Launch
Clone the repository and navigate to the project directory:
git clone https://github.com/A-Marbach/baby-tools-shop.git
cd baby-tools-shop
Copy the example environment file to create your local .env:
cp example.env .env
Build the Docker image:
docker build -t baby-tools-shop .
Run the application with Docker, setting it up to automatically manage restarts and data persistence:
docker run --restart unless-stopped -p 8025:8025 -v /path/to/your/data:/data baby-tools-shop
The application should now be accessible via http://localhost:8025.
Usage
Configuration
This application uses environment variables for configuration to enhance security and protect sensitive data. To set up the environment variables:
- Copy the example environment file to create your local
.env:
cp example.env .env
- Generate a secure Django SECRET_KEY and add it to your .env:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
- Copy the generated key and replace the placeholder in your
.env:
DATABASE_URL=postgres://username:password@localhost:5432/mydatabase
SECRET_KEY=<paste_your_generated_key_here>
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
⚠️ Important:
Do not commit your.envto Git.
Replace these values with secure ones to run the application safely.
Running the Application
After setting up the environment variables, you can start the application as follows:
docker run --env-file .env --restart unless-stopped -p 8025:8025 -v /path/to/your/data:/data baby-tools-shop
The application is now running on http://localhost:8025.
Admin Panel
After running the application, you can manage products and categories via the Django admin panel.
- Create an Admin User
To create a superuser account (admin), run:
docker exec -it <container_id> python manage.py createsuperuser
Follow the prompts to set your username, email, and password.
Screenshot of the superuser creation page:
This account will allow you to log in to the admin panel at http://localhost:8025/admin/.
- Add Categories
Log in to the admin panel with your superuser account.
Click on Categories → Add Category, fill in Name and Slug, then click Save.
Screenshot of Add Category page:
- Add Products
Click on Products → Add Product, fill in all required fields (Name, Description, Price, Category, Image), and then click Save.
Screenshot of Add Product page:
Repeat for all products you want to add.
Useful Commands
To further manage your application's lifecycle, you can execute the following Docker commands:
-
Apply database migrations: Execute the following command to apply migrations:
docker exec -it <container_id> python manage.py migrate -
Create an admin user: To create an admin user, use:
docker exec -it <container_id> python manage.py createsuperuser
Security Notes
- Do not store SSH keys, passwords, tokens, or usernames in your code. Use environment variables instead.
- Avoid storing sensitive information such as IP addresses in the Git repository.
- Follow the naming conventions for environment variables and shell variables to prevent errors in code interpretation.
Feel free to contribute to this project by submitting issues or pull requests. For any questions, please submit an issue on GitHub.
This update integrates the Docker configurations fully into the quick start and usage sections, emphasizing best practices for security and data persistence.