This is a web-based inventory management system built using Django.
- π€ Allows users to add, update, and delete products in the inventory.
- π Provides user authentication and authorization for secure access.
- π Supports pagination for better navigation through product lists.
- Clone the repository:
git clone https://github.com/ajmalrasouli/Inventory_app.git
Follow these steps to set up the project environment and run the server.
cd .\inventory_management\
python -m venv venv
Activate the Virtual Environment
venv\Scripts\activate
Install Dependencies To install the required dependencies, run:
pip install -r requirements.txt
Usage Apply Migrations To apply database migrations, run:
python manage.py makemigrations
python manage.py migrate
Create a Superuser To create a superuser, run:
python manage.py createsuperuser
Run the Server To start the development server, run:
python manage.py runserver
- Access the application at
http://127.0.0.1:8000/
.
- π Python
- π Django
- π HTML
- π¨ CSS
- β JavaScript
- π₯Ύ Bootstrap
This repository contains a Dockerized Django application for managing inventory. Follow the instructions below to set up and run the application locally using Docker.
Before you begin, make sure you have the following installed on your system:
- Docker π³
- Docker Compose π³
Clone this repository to your local machine using the following command:
git clone https://github.com/ajmalrasouli/Inventory_app.git
cd Inventory_app
Create a .env file in the root directory of the project and add the following environment variables:
DJANGO_SECRET_KEY=your_secret_key
DATABASE_URL=sqlite:///db.sqlite3
Replace your_secret_key with a secret key for your Django application.
Create a Dockerfile in the root directory of your project with the following content:
# Use the official Python image from the Docker Hub
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set the working directory inside the container
WORKDIR /code
# Copy the requirements file into the container
COPY requirements.txt /code/
# Install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Copy the entire project into the container
COPY . /code/
Create a docker-compose.yml file in the root directory with the following content:
version: '3.8'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
env_file:
- .env
Build and run the Docker container using the following command:
docker-compose up --build
In a new terminal, run the following commands to apply migrations and create a superuser:
docker-compose run web python manage.py makemigrations
docker-compose run web python manage.py migrate
docker-compose run web python manage.py createsuperuser
Open your web browser and go to http://localhost:8000 to access the Django application.
If you want to push your Docker image to Docker Hub, follow these steps:
- Build the Docker Image:
docker build -t your-dockerhub-username/inventory_app .
- Log in to Docker Hub:
docker login
- Push the Docker Image:
docker push your-dockerhub-username/inventory_app
Replace your-dockerhub-username with your actual Docker Hub username.
Description: A Dockerized Django Inventory Application Category: Application Full Description:
This repository contains a Dockerized Django application for managing inventory. The application includes features such as adding, editing, and deleting inventory items, and viewing inventory statistics.
- π€ User authentication and authorization
- π¦ Inventory management (CRUD operations)
- π Responsive web interface
- π REST API for integration with other systems
- π³ Docker
- π³ Docker Compose (optional)
- π» GitHub account
- π³ Docker Hub account
Ensure the following Dockerfile is present in the root of your project:
Copy code
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /code
# Copy the requirements file into the container
COPY requirements.txt /code/
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code to the working directory
COPY . /code/
# Run the command to start the Django server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
This Dockerfile uses the official Python 3.9 Slim image as the parent image and sets the working directory to /code. It then copies the requirements.txt file into the container and installs any needed packages. Next, it copies the rest of the application code to the working directory and runs the command python manage.py runserver 0.0.0.0:8000 to start the Django server.
Ensure the following GitHub Actions workflow is present at .github/workflows/docker-image.yml:
Copy code
name: Docker Image CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: your-dockerhub-username/inventory_app:latest
- name: Run tests
run: |
docker run --rm your-dockerhub-username/inventory_app:latest python manage.py test
- Navigate to the Settings tab in your GitHub repository. βοΈ
- Select Secrets and variables > Actions. π
- Click on New repository secret. π
- Add the following secrets:
- DOCKER_USERNAME: Your Docker Hub username. π€
- DOCKER_PASSWORD: Your Docker Hub password. π
Copy code
git add .
git commit -m "Add GitHub Actions workflow for Docker image build and push"
git push origin master
To build and run the Docker container locally:
docker-compose up --build
To access the application, open your browser and navigate to http://localhost:8000. π
Following the above steps will set up a GitHub Actions workflow for your inventory_app Django project. This workflow will build your Docker image, run tests, and push the image to Docker Hub every time you push to the master branch or create a pull request targeting the master branch. This setup ensures continuous integration and delivery (CI/CD) for your Dockerized Django application. π
If you would like to contribute to this project, please follow these steps:
- Fork the repository. π΄
- Create a new branch (git checkout -b feature-branch). π±
- Make your changes. βοΈ
- Commit your changes (git commit -m 'Add some feature'). π
- Push to the branch (git push origin feature-branch). π€
- Create a new Pull Request. π
This project is licensed under the MIT License - see the LICENSE file for details.