HE-Arc / webapp-server

Servers for the web application 2 course.
https://srvz-webapp.he-arc.ch/
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

WebApp Server

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

The setup scripts to create development environments for many groups.

Requirements

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:

Setup

The scripts require docker-compose as well as other dependencies.

$ python3 -m venv .
$ . bin/activate
(webapp-server)$ pip3 install -r requirements.txt

Docker-compose

Based on the TSV file, you can generate a Docker Compose YAML file.

$ scripts/make_compose.py eatapp \
    < students.tsv \
    > teams/eatapp-compose.yml

Then adapt the port number, and run it.

$ docker-compose -f teams/eatapp-compose.yml up

Database creation

Reusing the docker-compose.yml file, we create the databases.

$ scripts/bdd.py < teams/eatapp-compose.yml

Containers

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

# Base container
$ make base
# Laravel container
$ make laravel
# Python container
$ make python
# Rails container
$ make rails

Run via docker-compose

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

Run the container(s)

# create the shared network
$ docker network create --driver=bridge webapp-net

# running the central services
$ docker-compose up -d

# running "a" project
$ docker-compose -f examples/base.yml 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

Change the password either in the docker-compose.yml file or afterwards this way.

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

PostgreSQL

Change the password either in the docker-compose.yml file or afterwards this way.

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

Standalone setup

Below is a sample of a simple PHP machine with a MySQL instance. The default environment variable can be overridden (see scripts/boot.sh)

version: "3"

services:
  web:
    image: hearcch/webapp-server:laravel
    ports:
      - "8080:80"
      - "2222:22"
    environment:
      - GROUPNAME=test
      - PASSWORD=test
      - SSH_KEYS=greut
    volumes:
      - web:/var/www
    depends_on:
      - mysql

  mysql:
    image: mysql:5.7
    ports:
      - "3306:3306"
    environment:
      - MYSQL_DATABASE=test
      - MYSQL_USER=test
      - MYSQL_PASSWORD=test
      - MYSQL_RANDOM_ROOT_PASSWORD=1
    volumes:
      - mysql:/var/lib/mysql

volumes:
  web:
  mysql:

The login using your github SSH key.

$ ssh -p 2222 poweruser@127.0.0.1

Volumes and Windows

On non-UNIX filesystem, it's okay to mount a local folder a the /var/www volume. However, on Windows, don't do it and mount the container volume on the machine using SFTP(e.g. http://www.sftpnetdrive.com/)