Skip to content

Commit

Permalink
Videobridges live at convene-videobridge-$client.zinc.coop (#76)
Browse files Browse the repository at this point in the history
This allows us to use meet.zinc.coop for our convene domain for Zinc, as well as
renames the `jitsi` folder and other references to `videobridge` 

#61 
#74
  • Loading branch information
zspencer authored Aug 7, 2020
1 parent 7d5046c commit ebbb617
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 89 deletions.
2 changes: 1 addition & 1 deletion convene-web/app/models/demo_workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(client_repository)
# Creates the Convene Demo Workspace and Zinc Client if necessary
def find_or_create_workspace!
workspace = client.workspaces.find_or_create_by!(name: 'Convene Demo')
workspace.update!(jitsi_meet_domain: 'meet.zinc.coop',
workspace.update!(jitsi_meet_domain: 'convene-videobridge-zinc.zinc.coop',
branded_domain: 'convene-demo.zinc.coop',
access_level: :unlocked)
add_demo_rooms(workspace)
Expand Down
1 change: 0 additions & 1 deletion convene-web/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<script src='https://meet.zinc.coop/external_api.js'></script>
</head>

<body>
Expand Down
3 changes: 3 additions & 0 deletions convene-web/app/views/rooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
<% end %>
</ul>
</div>


<script src='https://<%= current_workspace.jitsi_meet_domain %>/external_api.js'></script>
2 changes: 1 addition & 1 deletion convene-web/app/views/workspaces/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<%= render partial: 'workspaces/room_card', locals: { room: room } %>
<% end %>
</ul>
</div>
</div>
2 changes: 1 addition & 1 deletion convene-web/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.find_or_create_by!(name: 'Zinc')
zincs_workspace.update!(access_level: :unlocked,
branded_domain: 'meet.zinc.local',
jitsi_meet_domain: 'meet.zinc.coop')
jitsi_meet_domain: 'convene-videobridge-zinc.zinc.coop')

zincs_workspace.members << zee
zincs_workspace.members << tom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@ variable "cloudflare_zone_id" {
type = string
}


variable "vultr_api_key" {
type = string
}

provider "cloudflare" {
version = "~> 2.0"
email = var.cloudflare_email
api_key = var.cloudflare_api_key
}

# Create a DNS record for the Jitsi Meet Host
resource "cloudflare_record" "meet" {
zone_id = var.cloudflare_zone_id
name = "meet"
value = vultr_server.convene_vultr_video.main_ip
type = "A"
ttl = 1
}

# Create a DNS Record for the convene-web instance deployed to Heroku

# Create a DNS Record for the convene-web instance deployed to Heroku
resource "cloudflare_record" "convene" {
zone_id = var.cloudflare_zone_id
name = "convene"
Expand All @@ -39,6 +36,16 @@ resource "cloudflare_record" "convene" {
ttl = 1
}

# Create a branded-domain for the Zinc workspace
resource "cloudflare_record" "meet" {
zone_id = var.cloudflare_zone_id
name = "meet"
value = "quiet-shark-e5n5v9yt13haqkprrhhjdidx.herokudns.com"
type = "CNAME"
ttl = 1
}

# Create a branded-domain for the Convene-demo workspace
resource "cloudflare_record" "convene-demo" {
zone_id = var.cloudflare_zone_id
name = "convene-demo"
Expand All @@ -47,10 +54,6 @@ resource "cloudflare_record" "convene-demo" {
ttl = 1
}

variable "vultr_api_key" {
type = string
}

provider "vultr" {
api_key = var.vultr_api_key
}
Expand All @@ -64,16 +67,25 @@ resource "vultr_ssh_key" "my_ssh_key" {
ssh_key = var.public_key
}

# Create a Vultr server
# Create a Vultr server for the videobridge
resource "vultr_server" "convene_vultr_video" {
snapshot_id = var.vultr_snapshot_id
region_id = "12"
plan_id = "201"
label = "meet.zinc.coop"
label = "convene-videobridge-zinc.zinc.coop"
firewall_group_id = vultr_firewall_group.convene_vultr_firewall_group.id
ssh_key_ids = [vultr_ssh_key.my_ssh_key.id]
}

# Create a DNS record for the videobridge
resource "cloudflare_record" "convene-videobridge-zinc" {
zone_id = var.cloudflare_zone_id
name = "convene-videobridge-zinc"
value = vultr_server.convene_vultr_video.main_ip
type = "A"
ttl = 1
}

# Create Vultr firewall group
resource "vultr_firewall_group" "convene_vultr_firewall_group" {
description = "convene_vultr_firewall_group"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cloudflare_zone_id = "211e94f01d483d1555310b9a19cf98dd"
vultr_snapshot_id = "3d75f13901998"
vultr_snapshot_id = "93e5f2c9afef3"
46 changes: 23 additions & 23 deletions infrastructure/features/video-workspaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ Feature: Video Workspaces
I want a Video Workspace

Scenario: Operator Builds an 8 person Video Workspace on AWS
When an Operator runs the `jitsi/build` command with:
| arguments |
| --region=us-west-1 |
| --provider=aws |
| --client-domain={{clientDomain}} |
Then a convene-jitsi-{{clientDomain}} is available within the us-west-1 region
When an Operator runs the `videobridge/build` command with:
| arguments |
| --region=us-west-1 |
| --provider=aws |
| --client={{client}} |
Then a convene-videobridge-{{client}} AMI is available within the us-west-1 region

Scenario: Operator Provisions an 8 person Video Workspace on AWS
Given an Operator has ran `jitsi/build` for {{clientDomain}}
When an Operator runs the `jitsi/provision` command with:
| arguments |
| --client-domain={{clientDomain}} |
Then a JITSI meet instance is available at https://{{clientDomain}}
Given an Operator has ran `videobridge/build` for {{client}}
When an Operator runs the `videobridge/provision` command with:
| arguments |
| --client={{client}} |
Then a JITSI meet instance is available at https://convene-videobridge-{{client}}.zinc.coop

Scenario: Operator Builds an 8 person Video Workspace on Vultr
When an Operator runs the `jitsi/build` command with:
| arguments |
| --region=12 |
| --provider=vultr |
| --client-domain={{clientDomain}} |
Then a convene-jitsi-{{clientDomain}} is available within region 12 (Silcon Valley)
When an Operator runs the `videobridge/build` command with:
| arguments |
| --region=12 |
| --provider=vultr |
| --client={{client}} |
Then a convene-videobridge-{{client}} is available within region 12 (Silcon Valley)

Scenario: Operator Provisions an 8 person Video Workspace on Vultr and specifiy ssh username
Given an Operator has ran `jitsi/build` for {{clientDomain}}
When an Operator runs the `jitsi/provision` command with:
| arguments |
| --client-domain={{clientDomain}} |
| --ssh-username=root |
Then a JITSI meet instance is available at https://{{clientDomain}}
Given an Operator has ran `videobridge/build` for {{client}}
When an Operator runs the `videobridge/provision` command with:
| arguments |
| --client={{client}} |
| --ssh-username=root |
Then a JITSI meet instance is available at https://convene-videobridge-{{client}}.zinc.coop
28 changes: 0 additions & 28 deletions infrastructure/jitsi/build

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"client_domain": "{{env `CLIENT_DOMAIN`}}",
"videobridge_domain": "{{env `VIDEOBRIDGE_DOMAIN`}}",
"instance_type": "t2.micro",
"region": "{{env `REGION`}}"
},
Expand All @@ -22,14 +22,14 @@
},
"instance_type": "{{user `instance_type`}}",
"ssh_username": "ubuntu",
"ami_name": "convene-jitsi-{{user `client_domain`}} {{timestamp}}"
"ami_name": "{{user `videobridge_domain`}} {{timestamp}}"
}],
"provisioners": [{
"environment_vars": [
"CLIENT_DOMAIN={{ user `client_domain` }}"
"VIDEOBRIDGE_DOMAIN={{ user `videobridge_domain` }}"
],
"type": "shell",
"script": "jitsi/install"
"script": "videobridge/install"
},
{
"type": "ansible",
Expand Down
38 changes: 38 additions & 0 deletions infrastructure/videobridge/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

for i in "$@"
do
case $i in
--client=*)
CLIENT="${i#*=}"
shift
;;
--videobridge-domain=*)
VIDEOBRIDGE_DOMAIN="${i#*=}"
shift
;;
--region=*)
REGION="${i#*=}"
shift
;;
--provider=*)
PROVIDER="${i#*=}"
shift
;;
esac
done


if [ -z ${VIDEOBRIDGE_DOMAIN+x} ];
then
VIDEOBRIDGE_DOMAIN="convene-videobridge-$CLIENT.zinc.coop"
fi
echo $VIDEOBRIDGE_DOMAIN

# Automated: Build AMI
packer build \
-var "videobridge_domain=${VIDEOBRIDGE_DOMAIN}" \
-var "region=${REGION}"\
videobridge/${PROVIDER}.json


Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ sudo apt-get -y install debconf-utils nginx-full

# We pipe a single command at a time into debconf-set-selections to configure
# See `man debconf-set-selections`
echo jitsi-videobridge jitsi-videobridge/jvb-hostname string $CLIENT_DOMAIN | sudo debconf-set-selections
echo jitsi-meet-prosody jitsi-videobridge/jvb-hostname string $CLIENT_DOMAIN | sudo debconf-set-selections
echo jitsi-videobridge jitsi-videobridge/jvb-hostname string $VIDEOBRIDGE_DOMAIN | sudo debconf-set-selections
echo jitsi-meet-prosody jitsi-videobridge/jvb-hostname string $VIDEOBRIDGE_DOMAIN | sudo debconf-set-selections
echo "jitsi-meet-web-config jitsi-meet/cert-choice select Generate a new self-signed certificate (You will later get a chance to obtain a Let's encrypt certificate)" | sudo debconf-set-selections
echo jitsi-meet-web-config jitsi-meet/cert-path-crt string /etc/ssl/$CLIENT_DOMAIN.crt | sudo debconf-set-selections
echo jitsi-meet-web-config jitsi-meet/cert-path-key string /etc/ssl/$CLIENT_DOMAIN.key | sudo debconf-set-selections
echo jitsi-meet-web-config jitsi-meet/cert-path-crt string /etc/ssl/$VIDEOBRIDGE_DOMAIN.crt | sudo debconf-set-selections
echo jitsi-meet-web-config jitsi-meet/cert-path-key string /etc/ssl/$VIDEOBRIDGE_DOMAIN.key | sudo debconf-set-selections

sudo apt-get -y install jitsi-meet
sudo rm /usr/share/jitsi-meet/images/watermark.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ SSH_USERNAME='ubuntu'
for i in "$@"
do
case $i in
--client-domain=*)
CLIENT_DOMAIN="${i#*=}"
--client=*)
CLIENT="${i#*=}"
shift
;;
--videobridge-domain=*)
VIDEOBRIDGE_DOMAIN="${i#*=}"
shift
;;
--flush-dns-cache)
Expand All @@ -18,17 +22,22 @@ case $i in
esac
done

if [ -z ${VIDEOBRIDGE_DOMAIN+x} ];
then
VIDEOBRIDGE_DOMAIN="convene-videobridge-$CLIENT.zinc.coop"
fi
echo $VIDEOBRIDGE_DOMAIN

# TODO: Figure out how to share the secrets safely and the terraform.tstate
# (push/pull from private bucket? Spin up a consul instance?)
(cd clients/$CLIENT_DOMAIN && terraform init &&
(cd clients/$CLIENT && terraform init &&
terraform apply -var-file public.tfvars -var-file secrets.tfvars)

# Push the certbot install script that works for Ubuntu 20.04 to the server
if [ $FLUSH_DNS_CACHE ]; then
echo "Flushing DNS cache"
sudo killall -HUP mDNSResponder
fi
echo $CLIENT_DOMAIN
scp jitsi/install-letsencrypt-cert.sh $SSH_USERNAME@$CLIENT_DOMAIN:
ssh -t $SSH_USERNAME@$CLIENT_DOMAIN 'sudo ./install-letsencrypt-cert.sh'
echo $VIDEOBRIDGE_DOMAIN
scp videobridge/install-letsencrypt-cert.sh $SSH_USERNAME@$VIDEOBRIDGE_DOMAIN:
ssh -t $SSH_USERNAME@$VIDEOBRIDGE_DOMAIN 'sudo ./install-letsencrypt-cert.sh'
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"variables": {
"vultr_api_key": "{{env `VULTR_API_KEY`}}",
"client_domain": "{{env `CLIENT_DOMAIN`}}",
"videobridge_domain": "{{env `VIDEOBRIDGE_DOMAIN`}}",
"instance_type": "201",
"region": "{{env `REGION`}}"
},
"builders": [
{
"type": "vultr",
"api_key": "{{user `vultr_api_key`}}",
"snapshot_description": "convene-jitsi-{{user `client_domain`}} {{timestamp}}",
"snapshot_description": "{{user `videobridge_domain`}} {{timestamp}}",
"region_id": "{{user `region`}}",
"plan_id": "{{user `instance_type`}}",
"os_id": "387",
Expand All @@ -19,10 +19,10 @@
],
"provisioners": [{
"environment_vars": [
"CLIENT_DOMAIN={{ user `client_domain` }}"
"VIDEOBRIDGE_DOMAIN={{ user `videobridge_domain` }}"
],
"type": "shell",
"script": "jitsi/install"
"script": "videobridge/install"
},
{
"type": "ansible",
Expand Down

0 comments on commit ebbb617

Please sign in to comment.