josmas / local-badgr-server

A local setup of Badgr.io to use as a development dependency
Other
3 stars 3 forks source link

Badgr-server local setup

This is a development setup, not intended for production. It is intended to be used as a local Badgr server in an scenario in which Badgr is used as a dependency. One such case is PaperBadger, but it can be used for any other projects. This is not a development environment for the Badgr server itself, but a way to easily run the server within a local setup to be used as a dependency. As such, the Badgr sources are hosted within the container (not shared with the host), the latest code on github (at install time) will be pulled in, and the installation relies on a local sqlite3 db.

The instructions to install Badgr are not very clear, so this container may be pulling in more (hopefully no less) dependencies that it actually needs.

How to build the image

Build the image with:

docker build -t <your_name>/local-badgr-server .

Do not forget the dot at the end of the build command, and change your_name to your docker hub username or some other name of your choosing.

The image is based on Ubuntu 14.04, and it creates a 'badgr' user with no password and in the sudoers group. The sources are at /home/badgr/badgr-server.

How to use the image

You can use the script runBashBadgr.sh to start a bash session with the badgr user. Make sure you modify the script to change __ to the name you used when building the image. The script simply runs a bash session in the container so you can take it from there. You can run it manually with:

docker run -ti --rm --name local-badgr-server -p 8000:8000 <your_name>/local-badgr-server /bin/bash

The database copied into the container contains an Issuer, a number of badges, and a number of badge instances. It also contains a superuser: the username and password are admin, and the email address is b@d.gr.

Start up the server with:

./manage.py runserver 0.0.0.0:8000

As specified in the Dockerfile, virtualenv is not used, but everything is in place if you would like to do so.

Note that any changes you make to either the container, the code, or the DB, will have to be persisted through docker commit if they need to be available when you restart the container.

Notes for Mac and Windows users

If you are not on Docker Beta, and your Docker does not run natively, this server will be available in an ip such as http://192.168.99.100:8000/. Make sure you make the appropriate changes when needed.

You will also have to change the HTTP_ORIGIN variable in the local settings file apps/mainsite/settings_local.py to point to your ip:port. More info about why that change is needed.

Notes about the Badgr server

The Badgr server verifies all accounts (including the superuser) through email. When creating an account (or logging in for the first time as a superuser), the server will print the verification URL in the terminal as a log statement. This URL can be copied and pasted in the browser to verify the account. For more information about the Badgr-server, please consult their docs.

Jos - May 2o16