Skip to content

flavienbwk/etna-rank

Repository files navigation

ETNA Rank

Dev build Prod build

Unofficial ranking page for ETNA students.

ETNA Rank logo

Why ?

ETNA-rank allows you to keep track of your Grade Point Average (GPA) for your current year of formation. You need an ETNA account to log-in.

👉 Want to contribute ? Feel free to open a pull request or fill an issue !

Why we need to ask for your password ?

We first tried to build ETNA-rank as an app-only project. However, built-in securities in all major browsers don't allow for cross-site authentication token retrieval.

Your password is NEVER stored. You can check our code.

If you're still afraid about us storing your password, run the project by yourself following the steps below. But again : we - don't - store - your - password.

Run the project (development)

Run each of these commands one after the other :

docker-compose build
docker-compose up -d

Access to the app at https://localhost:10102

Run the project (staging)

This build is for making sure etna-rank is self-contained with all necessary dependencies and configuration to be deployed for production as well as being ready for Kubernetes.

Steps for running the project as staging

Run each of these commands one after the other :

# Setting up certificates
mkdir ./certs
chmod 700 ./certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./certs/app.key -out ./certs/app.crt
openssl dhparam -out ./certs/dhparam.pem 2048

# Running web platform
docker-compose -f prod.docker-compose.yml build
docker-compose -f prod.docker-compose.yml up -d

Access to the app at https://localhost:10102

Deploy the project (production, Ansible)

ℹ️ We recommend using VPS Instances from Scaleway

Steps for deploying the project with Ansible

At this step, we expect you to have :

  • Ansible installed on your machine
  • A configured SSH access with your VPS

The following role was tested with Ubuntu 22.04 only.

# CHANGE remote_host AND ansible_user WITH YOURS
ansible-playbook -i ./ansible/inventory.ini ./ansible/deployment.yml --extra-vars "ansible_user=root remote_host=xxx.xxx.xxx.xxx domain=etna.tk"

This playbook exposes port 443 of the machine

Deploy the project (production, K8S)

⚠️ We recommend using Kubernetes Kapsules from Scaleway. At this step, we expect you to have a working Kubernetes configuration with Ingress installed.

Steps for deploying the project with Kubernetes
  1. Create namespace

    kubectl create ns etna-rank
  2. Update ingress endpoint

    In ./k8s/ingress.yaml, edit the 964c196d-dee5-41e2-b8ae-a11acfbdd425.nodes.k8s.fr-par.scw.cloud prefix accordingly to your Scaleway configuration.

  3. Tagging and pushing images (ETNA-rank development team only)

    First, you need a container Registry to then tag your images. Here is an example :

    # Nginx container
    docker build ./nginx -f ./nginx/k8s.Dockerfile -t ghcr.io/flavienbwk/etna-rank/nginx:latest
    docker push ghcr.io/flavienbwk/etna-rank/nginx:latest
    
    # App container
    docker build ./app -f ./app/prod.Dockerfile -t ghcr.io/flavienbwk/etna-rank/app:latest
    docker push ghcr.io/flavienbwk/etna-rank/app:latest
    
    # API container
    docker build ./api -f ./api/prod.Dockerfile -t ghcr.io/flavienbwk/etna-rank/api:latest
    docker push ghcr.io/flavienbwk/etna-rank/api:latest
  4. Run etna-rank (app & API)

    kubectl apply -f ./k8s

Run the project (production, serverless)

Want to go serverless ? You might want to host this project on Scaleway Containers instances.

Steps for deploying the project serverless

We first need to deploy our API so our app can know what the API endpoint is.

  1. Get your Container Registry endpoint

    export SCW_REGISTRY=rg.fr-par.scw.cloud/funcscwetnarankpduzntz8
  2. Build and ship the API

    In this step we're going to :

    • Build the API image
    • Tag and push it to your provided Scaleway's Containers Registry
    • Retrieve API's URI (i.e: https://etnarankpddqzdf6-api.functions.fnc.fr-par.scw.cloud)
    _IMAGE_API=$SCW_REGISTRY/api
    _TAG_API=latest
    TAG=$_TAG_API IMAGE_API=$_IMAGE_API docker-compose -f prod.docker-compose.yml build api
    docker push "$_IMAGE_API:$_TAG_API"

    Deploy your container with appropriate env variables.

  3. Defining API endpoint

    Create your .env file :

    cp .env.example .env

    In .env, edit the API_ENDPOINT and APP_ENDPOINT values with the container endpoint provided to you in the Container Settings tab of your API container.

  4. Build and ship the app

    In this step we're going to :

    • Build the app image with API endpoint
    • Tag and push it to your provided Scaleway's Containers Registry
    _IMAGE_APP=$SCW_REGISTRY/app
    _IMAGE_TAG=latest
    TAG=$_IMAGE_TAG IMAGE_APP=$_IMAGE_APP docker-compose -f prod.docker-compose.yml build app
    docker push "$_IMAGE_APP:$_IMAGE_TAG"

    Deploy your app container.