Skip to content

Installation

Evan J edited this page Oct 8, 2021 · 7 revisions

Manual

Prerequisites

Make sure you have a MySQL database running (use this to set it up via Docker) with the correct database schema

  1. Clone the repo by running $ git clone https://github.com/ejach/InventoryApplication.git
  2. cd into the cloned directory $ cd InventoryApplication
  3. 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
  1. 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.

  2. Run the program using python wsgi.py

Docker Run

$ docker run -it -e host=<host> -e port=<port> -e webui_host=<webui_host> -e webui_port=<webui_port> -e db_port=<db_port> -e db=<db> ghcr.io/ejach/inventoryapplication:latest

Change the corresponding environment variables as needed

Docker-Compose

  1. Run $ docker volume create --name db-data to create the volume used by the MySQL database
  2. 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
  1. Run $ docker-compose -f docker-compose.yml up -d

Docker Build

  1. Make sure you have a MySQL database running with the correct database schema
  2. Change the environment variables to your liking by exporting them shown in example.env
  3. Build the image using the existing Dockerfile by running $ docker build -t inventoryapplication .
  4. Run the newly created image using $ docker run inventoryapplication
Clone this wiki locally