blob: 02f8c3cf66a72719f13029d93565d0cd6f13b51c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# 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
```
base-devel
python3-devel
postgresql-libs-devel
```
On Void Linux. On Ubuntu machines it will be similar.
``` bash
cd app
virtualenv 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
./manage.py migrate
./manage.py createsuperuser
# 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:
``` bash
export CFG="my-config.yml"
cd app
virtualenv env
. env/bin/activate
pip install -r requirements.txt
cp config.yml $CFG
vi $CFG # This is where you change the SECRET_KEY, static_root, allowed_hosts
# and other settings.
cat uwsgi.ini | sed -e"s/config.yml/$CFG/g" > my-uwsgi.ini
./manage.py collectstatic
./manage.py migrate
./manage.py createsuperuser
uwsgi --ini my-uwsgi.ini # This will start the daemon, it's up to you to
# configure your OS to start it on boot
```
Below is a sample Nginx configuration, edit for your needs:
``` nginx
# It's up to you to configure HTTPs, I _highly_ recommend it
server {
listen 80;
# Uncomment if you have ipv6
# listen [::]:80;
server_name dispatch.example.com;
root /var/www/dispatch.example.com;
index index.html index.htm;
# Some applications have trouble with merged slashes
# This likely doesn't but worth noting
merge_slashes off;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9200;
}
# Pass through the static directory
# This should match whatever is in your config file
location /static {
alias /var/www/dispatch.example.com/static;
}
# This is probably going to be pulled from dispatch/static/robots.txt
location /robots.txt {
alias /var/www/dispatch.example.com/static/robots.txt;
}
# Enable logging
# You will likely have to create these directories for Nginx to load
access_log /var/log/nginx/dispatch.example.com/access.log;
error_log /var/log/nginx/dispatch.example.com/error.log;
}
```
## 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.
```
|