There is a need to have a system in place that allows for part inventory to be tracked over each of the company vans that SOS Irrigation utilizes. Each technician has an iPad or a personal device to use on the van, so by developing a web application to sync across all devices helps keep track of all inventory in each van. A database of each part SOS Irrigation uses is necessary to keep track of all inventory in the system. The database will have the ability to add or remove parts in inventory. A count of each available part on a given van will be visible to the user. The ability to see what parts are low in stock or missing is important to know what parts to order. It will export data from the system to generate a list of all the parts the company has in inventory.
Make sure you have a MySQL database running with the correct database schema
- Clone the repo by running
$ git clone https://github.com/ejach/InventoryApplication.git
cd
into the cloned directory$ cd InventoryApplication
- Change the environment variables to your liking by exporting them shown in
example.env
# Host for the MySQL database and the WebUI (default is localhost)
host=localhost
# Host for the WebUI
webui_host=localhost
# Port for the WebUI using a WSGI server (default is 5000 for development, 8000 for production)
webui_port=5000
# Username for the MySQL database (default is root)
username=root
# Password for the MySQL database (default is root)
password=root
# Port for the MySQL database (default is 3306)
db_port=3306
# Database schema name in the MySQL database (default is parts)
db_schema=parts
# Database table in the MySQL database (default is parts)
db=parts
# A string of text or characters used in the Flask sessions module
SECRET_KEY=YOURKEY
# Only use/uncomment if you are planning on deploying to Heroku; Default is False
DYNO=FALSE
# Need to have a TILL URL with the username/api embedded to use SMS
TILL_URL=xxx
-
Install the requirements
$ pip install -r requirements.txt
Make sure that your user has read/write permissions in the database/table that has been created or else it will not work.
-
Setup your database and add an admin account by running
$ python db_setup.py
-
Run the program using
python wsgi.py
$ docker run -it -e host=<host> -e db_port=<db_port> -e username=<username> -e password=<password> -e webui_host=<webui_host> -e webui_port=<webui_port> -e db_port=<db_port> -e db=<db> -e db_schema=<db_schema> ghcr.io/ejach/inventoryapplication:latest
Change the corresponding environment variables as needed
- Run
$ docker volume create --name db-data
to create the volume used by the MySQL database - Use the docker-compose file and edit the
environment
variables as needed:
version: '3.8'
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: parts
volumes:
- db-data:/var/lib/mysql
ports:
- "3308:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
restart: always
environment:
PMA_HOST: db
PMA_USER: root
PMA_PASSWORD: root
ports:
- "8080:80"
invapplication:
image: ghcr.io/ejach/inventoryapplication:latest
restart: always
environment:
host: db
webui_host: localhost
webui_port: 5000
username: root
password: root
db_port: 3306
db: parts
ports:
- "5000:8000"
volumes:
db-data:
external: true
- Run
$ docker-compose -f docker-compose.yml up -d
- Make sure you have a MySQL database running with the correct database schema
- Change the environment variables to your liking by exporting them shown in
example.env
- Build the image using the existing
Dockerfile
by running$ docker build -t inventoryapplication .
- Run the newly created image using
$ docker run inventoryapplication