By Shivan Sivakumaran
The is a website that contains common calculations performed by Optometrists and Optical Dispensers.
Below is the .env files which is stored in /app.
SECRET_KEY=<django secret key>
SENTRY=<DSN>
To run locally run:
make run
Ansible playbooks are used to set up the application on a 'production' server. The code for this can be found here.
This includes the nginx and certbot set up, which are on the server. The postgresql database, django and gunicorn app sit inside their own docker containers.
Gunicorn is used as a the wsgi service.
Docker-compose is used to orchestrate the entire project:
$ sudo docker-compose up --build
This is weird and I'm sure there are plenty workarounds. Since I do not have nginx running on my local machine, if I run the docker-compose command as if it were in production, the site will work. However, I will not have any static files. This is because nginx serves those static files. I use docker-compose to spin up at postgresql database and then run:
$ pipenv run python manage.py runserver
to create a local django instance, which is connected to the dockerised postresql database. I can a function application with static files that I can then make edits to my code.
Below is how the application is structured
├── db-data # Database
├── optomcalc
│ ├── calculator # application or 'calculator' code
│ │ ├── templates
│ │ │ └── calculator
│ │ └── tests
│ ├── optomcalc # admin app
│ └── static # static files for nginx
│ └── calculator
│ ├── css
│ └── js
Please contact me if you have any questions.