No description
Find a file
2021-02-20 15:00:04 +01:00
ansible Ansible scripts revised 2021-02-20 15:00:04 +01:00
bin Project name 2016-12-09 06:13:01 +01:00
docs Added screenshot 2019-05-16 14:44:47 +02:00
feedler Updated to Wagtail 2.11 2020-12-11 11:32:59 +01:00
publichealth Clean up bower setup 2021-02-20 13:55:55 +01:00
tests Wagtail 2 support 2019-06-14 22:02:15 +02:00
vagrant Clean up ruby install 2019-08-09 15:19:50 +02:00
.dockerfile Bumped Python ver and yarn 2020-02-18 17:18:59 +01:00
.dockerignore Deployment optimized 2019-09-09 19:38:13 +02:00
.editorconfig Bootstrap SASS theme 2016-12-12 23:43:20 +01:00
.gitignore Migrated from bower to yarn and from ruby-sass to node-sass 2019-08-09 15:17:25 +02:00
ansible.cfg Remove comments model due to django sites error 2020-05-18 14:13:12 +02:00
bitbucket-pipelines.yml bitbucket-pipelines.yml added 2017-01-18 14:26:48 +00:00
CHANGELOG.md Updated to Wagtail 1.13 2017-10-23 09:42:52 +02:00
fabfile.py Project name 2016-12-09 06:13:01 +01:00
Gruntfile.js Updated Bootstrap 3 frontend components 2020-05-27 12:16:55 +02:00
LICENSE.md Added license, updated README 2017-05-05 16:10:24 +02:00
Makefile Makefile and extra conf 2020-05-27 15:42:22 +02:00
manage.py Wagtail 2 support 2019-06-14 22:02:15 +02:00
package.json Added coffeescript 2021-02-20 14:05:22 +01:00
Pipfile Updated soupsieve 2020-05-18 10:28:59 +02:00
Pipfile.lock Ansible roles updated 2021-02-18 16:40:18 +01:00
Procfile Db config 2017-03-28 00:43:55 +02:00
README.md Ansible scripts revised 2021-02-20 15:00:04 +01:00
requirements-test.txt Updated deps 2020-02-18 17:01:31 +01:00
requirements.txt Updated to Wagtail 2.11 2020-12-11 11:32:59 +01:00
runtime.txt Python version 2017-03-27 23:32:32 +02:00
stellar.yaml Project name 2016-12-09 06:13:01 +01:00
Vagrantfile Project name 2016-12-09 06:13:01 +01:00
yarn.lock Added coffeescript 2021-02-20 14:05:22 +01:00

Public Health Schweiz

Website of the Swiss Society for Public Health, developed by datalets,ch using the open source, Django-based Wagtail CMS. The frontend is implemented by moving water using Bootstrap framework.

This project is open source under the MIT License.

Dependency Status

Development environment

The easiest way to set up your machine would be to use Vagrant, then in the project folder in the terminal type: vagrant up. Then when it is ready, follow instructions for publichealth/static/org/archive-message.html#Database setup.

To set up a full development environment, follow all these instructions.

Frontend setup

Make sure a recent version of node.js (we recommend using nave.sh), then:

npm install -g yarn grunt-cli
yarn install

The first command (..install -g..) may require sudo if you installed node.js as a system package. Afterwards, to compile the frontend, you should be able to run:

grunt

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. There is a grunt browser-sync setup for working with frontend assets.

(In a Vagrant shell, use the alias watch)

Backend setup

If not using Vagrant: after installing Python 3, from the project folder, deploy system packages and create a virtual environment as detailed (for Ubuntu users) below:

sudo apt-get install python3-venv python3-dev libjpeg-dev

pyvenv env
. env/bin/activate

pip install -U pip
pip install -r requirements.txt

At this point your backup is ready to be deployed.

Database setup

Once your installation is ready, you can get a blank database set up and add a user to login with.

If you are using Vagrant, enter the shell of your virtual machine now with vagrant ssh

Run these commands:

./manage.py migrate
./manage.py createsuperuser

You will be asked a few questions to create an administrator account.

Starting up

If you have one installed, also start your local redis server (service redis start).

After completing setup, you can use:

./manage.py runserver

(In a Vagrant shell, just use djrun)

Now access the admin panel with the user account you created earlier: http://localhost:8000/admin/

Troubleshooting

Issues with migrating database tables in SQLite during development? Try ./manage.py migrate --fake

Having trouble installing any packages with npm or yarn? Add IPv6 addresses to your hosts:

2606:4700::6810:1823 registry.npmjs.org 2606:4700::6810:1123 registry.yarnpkg.com

Production notes

We use Ansible and Docker Compose for automated deployment.

To use Docker Compose to manually deploy the site, copy ansible/roles/web/templates/docker-compose.j2 to /docker-compose.yml and fill in all {{ variables }}. This can also be done automatically in Ansible.

To update all roles from Ansible Galaxy used in our install scripts:

ansible-galaxy install `ls ansible/roles -x -I wagtail` --force

To check that the scripts and roles are correctly installed, use this command to do a "dry run":

ansible-playbook ansible/*.yaml -i ansible/inventories/lagoon --list-tasks

If you only want to run a certain set of actions, subset the tags which you see in the output above. For example, to only update the NGINX configuration:

ansible-playbook ansible/web.yaml -i ansible/inventories/lagoon --tags "nginx_template_config"

To do production deployments, you need to obtain SSH and vault keys from your system administrator (who has followed the Ansible guide to set up a vault..), and place these in a .keys folder. To deploy a site:

ansible-playbook ansible/*.yaml -i ansible/inventories/lagoon

For an update release with a specific version (tag or branch), use (the -v parameter showing output of commands):

ansible-playbook ansible/site.yaml -i ansible/inventories/lagoon --tags release -v -e gitversion=<v*.*.*>

You can also use the gitrepo parameter to use a different fork of the source code.

Once the basic system set up, i.e. you have an ansible user in the sudoers and docker group, you are ready to run the playbook.

Production releases

For further deployment and system maintenance we have a Makefile which automates Docker Compose tasks. This should be converted to use Ansible Container. In the meantime, start a release with Ansible, then complete it using make, i.e.:

ansible-playbook -i ansible/inventories/lagoon --tags release ansible/wagtail.yaml
ssh -i .keys/ansible.pem ansible@<server-ip> "cd <release_dir> && make release"

This is already part of the normal release cycle, but if you wish to update the Docker images to the latest versions separately, use:

make upgrade

Restoring a data backup

For development, it's handy to have access to a copy of the production data. To delete your local database and restore from a file backup, run:

rm publichealth-dev.sqlite3
python manage.py migrate
python manage.py loaddata publichealth.home.json

You might want to createsuperuser again at this point.