Servers for the web application 2 course.
Python Nginx Shell PHP Ruby HTML
Latest commit 51cb07a Feb 3, 2017 @greut greut Simplification of the postgresql step.
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
Permalink
Failed to load latest commit information.
config
docker Simplification of the postgresql step. Feb 3, 2017
files Fix proxy_pass. Jan 30, 2017
runit
scripts
.gitignore Generating index.html file too. Dec 20, 2016
README.md
build.yml Python3 container using uwsgi Nov 22, 2016
docker-compose.yml Big refactoring... Dec 9, 2016
requirements.txt

README.md

WebApp Server

Join the chat at https://gitter.im/HE-Arc/webapp-server

The setup scripts to create development environments for many groups.

Requirements

  • Docker >1.13
  • Python 3 (pip & venv)
  • libyaml-dev

Setup

Students

The configuration is done via a TSV file (config/students.tsv). Here is its format:

Lastname Firstname Email Group Github Image1 Team1 Image2 Team2 Comment
Bon Jean jean.bon@example.org INF3 jeanjean Laravel ninjas Rails funky -
Blanc Yoan yoan.blanc@he-arc.ch Teacher greut Laravel admin Python admin -

This is how this file is used:

  • Lastname no particular usage
  • Firstname becomes the username
  • Group no particular usage
  • GitHub identifier to download the SSH public keys
  • ImageX stores the information of which container to use
  • TeamX will be the name of the virtual host and identify a container
  • Comment no particular usage

Public keys

To download the public keys, run this python script:

# setup
$ python3 -m venv .
$ . bin/activate
$ pip3 install -r requirements.txt

$ scripts/github_keys.py config/students.tsv config/keys/ <github_username> <password_or_key>

The key is a personal access token to avoid being rate limited by the API.

Docker-compose

Based on the same TSV file, you can generate docker-compose.yml file.

$ scripts/rails_compose.py config/students.tsv docker-compose.yml

Database creation

$ script/bdd.py docker-compose.yml

Containers

If you don't want to use the publicly available containers, you can build them yourself.

# Base container
$ docker-compose -f build.yml build base
# Laravel container
$ docker-compose -f build.yml build laravel
# Python container
$ docker-compose -f build.yml build python
# Rails container
$ docker-compose -f build.yml build rails

Run via docker-compose

Create a docker-compose.yml file base on the sample one.

Run the container(s)

docker-compose up -d

Databases

The databases are open the external world, hence we must modify the super admin password. Setting up a good one during the startup won't be as effective as it will be visible from within the containers anyway.

MySQL

Post-setup

Changing MySQL root password because the above value will be passed to each linked containers.

# 5.6
$ mysqladmin -h 127.0.0.1 -u root -p'root' password 's3cur3@P45sw0rd'

# 5.7
$ mysql -h 127.0.0.1 -u root -proot
> SET PASSWORD FOR 'root'@'%' = PASSWORD('s3cur3@P45sw0rd');

PostgreSQL

Changing Postgres password because the above value will be passed to each linked containers.

$ psql -h 127.0.0.1 \
    -U postgres \
    -c "ALTER USER postgres WITH PASSWORD 's3cur3@P45sw0rd';"