Skip to content

Commit

Permalink
Merge pull request #3095 from input-output-hk/marlowe-web
Browse files Browse the repository at this point in the history
Marlowe web
  • Loading branch information
gilligan committed Apr 30, 2021
2 parents 943472f + 0d8362c commit ea7e0c6
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 3 deletions.
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ rec {
}) client;
};

marlowe-web = pkgs.callPackage ./marlowe-website { inherit (plutus.lib) npmlock2nix gitignore-nix; };

plutus-pab = pkgs.recurseIntoAttrs (pkgs.callPackage ./plutus-pab-client {
inherit (plutus.lib) buildPursPackage buildNodeModules gitignore-nix filterNpm;
inherit haskell webCommon webCommonPlutus;
Expand All @@ -98,7 +100,7 @@ rec {
deployment = pkgs.recurseIntoAttrs (pkgs.callPackage ./deployment/morph {
plutus = {
inherit plutus-pab marlowe-app marlowe-companion-app marlowe-follow-app
marlowe-dashboard marlowe-playground plutus-playground web-ghc docs;
marlowe-dashboard marlowe-playground plutus-playground web-ghc docs marlowe-web;
};
});

Expand Down
13 changes: 12 additions & 1 deletion deployment/morph/machines/playground.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
];

networking = {
firewall.allowedTCPPorts = [ 22 80 8080 9080 ];
firewall.allowedTCPPorts = [ 22 80 8080 8181 9080 ];
};

services.marlowe-playground = {
Expand Down Expand Up @@ -59,6 +59,17 @@
marlowe-playground.servers."127.0.0.1:4001" = { };
};
virtualHosts = {
"marlowe-web" = {
listen = [{ addr = "0.0.0.0"; port = 8181; }];
locations = {
"/" = {
root = "${pkgs.marlowe-web}";
extraConfig = ''
${staticFileCacheControl}
'';
};
};
};
"plutus-playground" = {
listen = [{ addr = "0.0.0.0"; port = 8080; }];
locations = {
Expand Down
1 change: 1 addition & 0 deletions deployment/morph/mk-machine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
marlowe-follow-app = plutus.marlowe-follow-app;
marlowe-dashboard = plutus.marlowe-dashboard;
marlowe-playground = plutus.marlowe-playground;
marlowe-web = plutus.marlowe-web;
plutus-playground = plutus.plutus-playground;
web-ghc = plutus.web-ghc;
plutus-docs = plutus.docs;
Expand Down
28 changes: 28 additions & 0 deletions deployment/terraform/certificates.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,31 @@ resource "aws_acm_certificate_validation" "marlowe_dash_private" {
certificate_arn = aws_acm_certificate.marlowe_dash_private.arn
validation_record_fqdns = [for record in aws_route53_record.marlowe_dash_private : record.fqdn]
}

# Marlowe Web SSL Certificate
resource "aws_acm_certificate" "marlowe_web_private" {
domain_name = "*.${var.marlowe_web_tld}"
validation_method = "DNS"
}

resource "aws_route53_record" "marlowe_web_private" {
for_each = {
for dvo in aws_acm_certificate.marlowe_web_private.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}

allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = var.marlowe_web_public_zone
}

resource "aws_acm_certificate_validation" "marlowe_web_private" {
certificate_arn = aws_acm_certificate.marlowe_web_private.arn
validation_record_fqdns = [for record in aws_route53_record.marlowe_web_private : record.fqdn]
}
50 changes: 50 additions & 0 deletions deployment/terraform/loadbalancing.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ resource "aws_security_group" "public_alb" {
cidr_blocks = var.private_subnet_cidrs
}

egress {
from_port = local.marlowe_web_port
to_port = local.marlowe_web_port
protocol = "TCP"
cidr_blocks = var.private_subnet_cidrs
}

tags = {
Name = "${local.project}_${var.env}_public_alb"
Project = local.project
Expand Down Expand Up @@ -97,6 +104,11 @@ resource "aws_alb_listener" "playground" {
}
}

resource "aws_lb_listener_certificate" "marlowe_web" {
listener_arn = aws_alb_listener.playground.arn
certificate_arn = aws_acm_certificate.marlowe_web_private.arn
}

resource "aws_lb_listener_certificate" "marlowe" {
listener_arn = aws_alb_listener.playground.arn
certificate_arn = aws_acm_certificate.marlowe_private.arn
Expand All @@ -107,6 +119,44 @@ resource "aws_lb_listener_certificate" "marlowe_dash" {
certificate_arn = aws_acm_certificate.marlowe_dash_private.arn
}

resource "aws_alb_listener_rule" "marlowe-web" {
listener_arn = aws_alb_listener.playground.arn
action {
type = "forward"
target_group_arn = aws_alb_target_group.marlowe_web.id
}

condition {
host_header {
values = [local.marlowe_web_domain_name]
}
}
}

resource "aws_alb_target_group" "marlowe_web" {
port = "80"
protocol = "HTTP"
vpc_id = aws_vpc.plutus.id
}

resource "aws_alb_target_group_attachment" "marlowe_web" {
target_group_arn = aws_alb_target_group.marlowe_web.arn
target_id = aws_instance.playgrounds_a.id
port = local.marlowe_web_port
}

resource "aws_route53_record" "marlowe_web_alb" {
zone_id = var.marlowe_web_public_zone
name = local.marlowe_web_domain_name
type = "A"

alias {
name = aws_alb.plutus.dns_name
zone_id = aws_alb.plutus.zone_id
evaluate_target_health = true
}
}

## ALB rule for web-ghc
resource "aws_alb_target_group" "webghc" {
# ALB is taking care of SSL termination so we listen to port 80 here
Expand Down
2 changes: 2 additions & 0 deletions deployment/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ locals {
marlowe_domain_name = "${var.marlowe_full_domain != "" ? var.marlowe_full_domain : "${var.env}.${var.marlowe_tld}"}"
plutus_domain_name = "${var.plutus_full_domain != "" ? var.plutus_full_domain : "${var.env}.${var.plutus_tld}"}"
marlowe_dash_domain_name = "${var.env}.${var.marlowe_dash_tld}"
marlowe_web_domain_name = "${var.env}.${var.marlowe_web_tld}"

marlowe_web_port = 8181
plutus_playground_port = 8080
marlowe_playground_port = 9080
pab_port = 9080
Expand Down
7 changes: 7 additions & 0 deletions deployment/terraform/playgrounds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ resource "aws_security_group" "playgrounds" {
cidr_blocks = concat(var.public_subnet_cidrs, var.private_subnet_cidrs)
}

ingress {
from_port = local.marlowe_web_port
to_port = local.marlowe_web_port
protocol = "TCP"
cidr_blocks = concat(var.public_subnet_cidrs, var.private_subnet_cidrs)
}

## outgoing: all
egress {
from_port = 0
Expand Down
8 changes: 8 additions & 0 deletions deployment/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ variable "marlowe_dash_tld" {
default = "marlowe-dash.iohkdev.io"
}

variable "marlowe_web_public_zone" {
default = "Z09016162N4S3NFVWHXYP"
}

variable "marlowe_web_tld" {
default = "marlowe-web.iohkdev.io"
}

variable "marlowe_dash_public_zone" {
default = "Z04600362E06M9P9U3Y12"
}
Expand Down
11 changes: 11 additions & 0 deletions marlowe-website/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ pkgs, lib, gitignore-nix, npmlock2nix }:

npmlock2nix.build {
src = gitignore-nix.gitignoreSource ./.;
installPhase = "cp -r public $out";

node_modules_attrs = {
packageLockJson = ./package-lock.json;
packageJson = ./package.json;
};
}
2 changes: 1 addition & 1 deletion nix/tests/vm-tests/plutus-playground.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
FRONTEND_URL="http://localhost:8080"
GITHUB_CALLBACK_PATH="/#/gh-oauth-cb"
GITHUB_CLIENT_ID="314123123a312fe"
GITHUB_CLIENT_SECRET=kljfks234dskjhfeskjr"
GITHUB_CLIENT_SECRET="kljfks234dskjhfeskjr"
'';
in
makeTest {
Expand Down

0 comments on commit ea7e0c6

Please sign in to comment.