public-health-ch/README.md

103 lines
3.4 KiB
Markdown
Raw Normal View History

Public Health Schweiz
=====================
2017-04-25 14:05:02 +00:00
New website of the [Swiss Society for Public Health](http://public-health.ch), developed by [datalets,ch](http://datalets.ch) using the open source, [Django](https://www.djangoproject.com/)-based [Wagtail CMS](http://wagtail.io). The frontend has been implemented by [moving water](http://www.movingwater.ch/) using [Bootstrap](https://getbootstrap.com) framework.
> Nota bene: this is a work in progress, licensing details and live site coming soon!
2016-12-12 22:43:20 +00:00
## Development environment
The easiest way to set up your machine would be to use [Vagrant](https://vagrantup.com), then in the project folder in the terminal type: `vagrant liverun`.
To set up a full development environment, follow all these instructions.
**Frontend setup**
You will need to have Ruby and SASS installed on your system, e.g.:
2016-12-14 09:43:06 +00:00
```
sudo yum install rubygem-sass
2016-12-14 09:43:06 +00:00
```
Make sure a recent version of node.js (we recommend using [nave.sh](https://github.com/isaacs/nave)), then:
```
npm install -g bower grunt-cli
npm install
bower install
```
The first command (`..install -g..`) may require `sudo` if you installed node.js as a system package.
If you are only working on the frontend, you can start a local webserver and work on frontend assets without the backend setup described below. Mock content is at `publichealth/static/mockup`
2016-12-14 09:43:06 +00:00
**Backend setup**
After installing Python 3, from the project folder, deploy system packages and create a virtual environment as detailed (for Ubuntu users) below:
2016-12-12 22:43:20 +00:00
```
2016-12-19 10:32:58 +00:00
sudo apt-get install python3-venv python3-dev libjpeg-dev
pyvenv env
. env/bin/activate
pip install -U pip
pip install -r requirements.txt
./manage.py migrate
./manage.py createsuperuser
2016-12-12 22:43:20 +00:00
```
2016-12-12 22:44:06 +00:00
2016-12-14 09:43:06 +00:00
You will be asked a few questions to create an administrator account.
**Starting up**
2016-12-14 09:43:06 +00:00
If you have one installed, also start your local redis server (`service redis start`).
2016-12-14 09:43:06 +00:00
Run this after completing setup:
```
./manage.py runserver &
2016-12-12 22:44:06 +00:00
grunt browser-sync
```
2016-12-14 09:43:06 +00:00
A default browser should open pointing to the default home page.
Now access the admin panel with the user account you created earlier: http://localhost:3000/admin/
2017-03-03 17:13:31 +00:00
## Troubleshooting
- Issues with migrating database tables in SQLite during development? Try `./manage.py migrate --fake`
2017-03-27 21:32:32 +00:00
## Production notes
We use [Ansible](https://www.ansible.com) and [Docker Compose](https://docs.docker.com/compose/reference/overview/) for automated deployment.
You need to obtain SSH and vault keys, and place these in a `.keys` folder - then to deploy a site:
```
ansible-playbook -s ansible/<*.yaml> -i ansible/inventories/production
```
We use a StackScript to deploy to Linode, the basic system set up is to have a user in the sudoers and docker group, and a few basic system packages ready.
For example, on Ubuntu:
2017-03-27 21:32:32 +00:00
2017-04-24 12:22:51 +00:00
```
apt-get install -q -y zip git nginx python-virtualenv python-dev
2017-04-24 12:22:51 +00:00
```
The order of deployment is:
- docker.yaml (base system)
- node.yaml
- site.yaml
- harden.yaml
2017-04-26 13:37:15 +00:00
For further deployment and system maintenance we have a `Makefile` which automates Docker Compose tasks. This should be converted to use [Ansible Container](http://docs.ansible.com/ansible-container/getting_started.html). In the meantime, start a release with Ansible, then complete it using `make`, i.e.:
```
ansible-playbook -s ansible/site.yaml -i ansible/inventories/production --tags release
2017-04-26 13:57:01 +00:00
ssh -i .keys/ansible.pem ansible@<server-ip> "cd <release_dir> && make release"
2017-04-26 13:37:15 +00:00
```