Skip to content

StoKa TV

Ruben Horn edited this page Jan 28, 2023 · 6 revisions

StoKa-TV

A TV application for displaying images and ads in the StoKa.
The code is available in this repository.

Instructions

  • Create a deployment with podman-compose -f deployment-compose.yaml up --build -d.
    (Before logging out you might need to run loginctl enable-linger $UID to avoid the container being stopped.)
  • Remove a deployment with podman-compose -f deployment-compose.yaml down.
  • To check if the app is ready, you can check if the ports 3100, 3101 and 3102 are open using sudo netstat -tulpna | grep LISTEN.
  • If you change the nginx config, you should run sudo nginx -s reload.

Files for deployment

The following modified files were used to cerate for the deployment.

Nginx config:

(This file should be placed in /etc/nginx/sites-enabled/stoka-tv.conf.)

server {
  server_name stoka-tv.storm.vu;
  listen 80;
  listen [::]:80;
  location /.well-known {
    root /usr/share/nginx/html/;
  }
  location / {
    return 301 https://$host$request_uri;
  }
}

server {
  server_name stoka-tv.storm.vu;
  listen [::]:443 ssl http2; # managed by Certbot
  listen 443 ssl http2;
  location /.well-known {
    root /usr/share/nginx/html/;
  }

  location / {
    access_log off;
    expires 1h;
    proxy_pass http://localhost:3101;
  }

  location /api {
    access_log off;
    expires 1h;
    proxy_pass http://localhost:3100;
  }

  location /admin {
      proxy_pass http://localhost:3102/;
  }

  ssl_certificate <REDACTED>;
  ssl_certificate_key <REDACTED>;
}

Modified Docker Compose file:

# Deployment compose file:
version: '3.8'

volumes:
  media:

services:
  admin:
    hostname: admin
    image: filegator/filegator
    restart: unless-stopped
    volumes:
      - media:/var/www/filegator/repository
      # Persist configuration (credentials, etc.)
      - /var/www/filegator/private
    ports:
      - 3102:8080

  backend:
    hostname: backend
    restart: always
    volumes:
      - media:/srv/media:ro
    build:
      context: ./backend
    environment:
      - NODE_ENV=production
      - DEBUG=""
    command: [ npm, run, start ]
    ports:
      - 3100:8080

  frontend:
    depends_on:
      - backend
    hostname: frontend
    restart: always
    build:
      context: ./frontend
    ports:
      - 3101:80

Syncing from Google Drive (deprecated)

(⚠️ This is not necessary when using direct file upload through filegator. Access can be recovered by opening a shell in the container and following the instructions here.)

  1. Get root_folder_id from a Google Drive URL (https://drive.google.com/drive/u/0/folders/<root_folder_id>)
  2. Follow the rclone documentation to create a service account file in the Google Cloud console and download the private key as a JSON file.
  3. Set up a new entry in the rclone configuration file.
[google-drive-stoka-tv]
type = drive
scope = drive
root_folder_id = <root_folder_id>
service_account_file = <path/to/service_account_file.json>
  1. Add a new CRON job that runs every five minutes by running crontab -e and adding the following line using the email address of the corresponding Google Drive accounts:
# */5 * * * * rclone sync google-drive-stoka-tv: ~/stoka-tv-media --drive-impersonate <REDACTED>
Clone this wiki locally