# dispatch-tracker Most of the features are here and the application should fulfill the use case at this time. ## Things to fix/add going forward: * Friendly Error pages * Description format field for customer objects & * on load create page dynamically pull in cursomter description format and display above the form field * Upload Invoice logos on Identity Objects for use in Invoices * Change Name To "Load Pay System" -- we're going to think about it * Freight Invoicing System * Figure out if auditlog timestamps are fucked or not with timezones ## To get a development system setup: Not strictly part of the Django app, but worth noting that if you have Postgres installed locally but don't want to muck with permissions, service etc it's as simple as: ```bash pg_ctl -D pg_data initdb pg_ctl -D pg_data -l pg_log start echo create database $(id -un)\; | psql postgres echo create database dispatch | psql ``` Your user should be able to connect with just a simple `psql` You will need to install Void Linux: ``` xbps-install base-devel python3-devel postgresql-libs-devel ``` Alpine Linux: ``` apk add git python3 py3-setuptools py3-virtualenv postgresql-client # This set can be optionally removed when the virutalenv is built apk add linux-headers postgresql-dev gcc python3-dev libc-dev ``` ``` bash cd app python3 -m venv env . env/bin/activate pip install -r requirements.txt cp config-example.yml config.yml sed -i.bak -e"s/USER: postgres$/USER: $(id -un)" config.yml python3 ./manage.py migrate python3 ./manage.py createsuperuser python3 ./manage.py setup_identity # This will create some fake records if you wish ./manage.py insert_fake_data --companies 10 --users 10 \ --loads 400 --start-date='-16w' --end-date='+16w' --attachments=true \ --invoices=true # Default is 2 weeks for start/end date, no # defaults for any other options # Run a local development server, listens to the world ./manage.py runserver 0.0.0.0:8080 ``` ## To get a production system setup: Alpine Linux is used as the example, but it should be similar for most systems: ``` bash # psql -U postgres postgres=# create role dispatch with login password 'mypass'; postgres=# create database dispatch with owner dispatch; postgres=# \q # export _u="dispatch" $ export _home="/var/dispatch" # addgroup -S "$_u" # adduser -h "$_home" -G "$_u" -S -D "$_u" # # Add Nginx to the dispatch group, on Alpine you must edit /etc/group # since `gpasswd` doesn't exist. This is so Nginx can see the socket # But your application can't see everything else Nginx does. $ chmod 751 "$_home" # su -s /bin/sh "$_u" $ . /etc/profile $ cd $ git clone https://git.riedstra.us/mitch/dispatch-tracker.git $ cd dispatch-tracker/app $ python3 -m virtualenv env $ . env/bin/activate $ pip install -r requirements.txt $ cp config-example.yml config.yml $ vi config.yml # Set database credentials. Allowed hosts, Debug: false, # secret key, static root, etc $ python3 ./manage.py collectstatic $ python3 ./manage.py migrate $ python3 ./manage.py createsuperuser $ uwsgi --processes=1 --threads=4 \ --socket=/tmp/dispatch-tracker.sock \ --chmod-socket=664 --module wsgi:application ``` Now install the Nginx configuration, careful to use `unix:/tmp/dispatch-tracker.sock` for `uwsgi_pass`. If you're using `runit` you can use the following script for the service: ```bash #!/bin/sh _user="dispatch_demo" _app_pth="/var/dispatch/dispatch-tracker/app/" _socket="/tmp/dispatch-tracker.sock" exec chpst -u "$_user" sh -c " set -e cd \"$_app_pth\"; . env/bin/activate; exec uwsgi \ --die-on-term \ --processes=1 \ --threads=4 \ --socket=\"$_socket\" \ --chmod-socket=664 \ --module wsgi:application " ``` ## Docker Environment setup A quasi production esque setup using `uwsgi` ``` ./docker-compose up -d ``` Then ``` sh docker-scripts/setup.sh ``` Docker compose is configured to bring up the Nginx instance on http://172.21.23.2 If you're on Windows or MacOS I'm told can't access it directly via IP, so https://localhost:36200 should work instead. # Misc Name brainstorming / Use case: ``` Subcontractor invoicing system Subcontractor Freight Invoicing System A business solution for subcontractors that don't invoice you. ```