Skip to content

Commit

Permalink
add marlowe
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverca22 committed Jul 22, 2021
1 parent 1816240 commit 6c9af23
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 79 deletions.
2 changes: 1 addition & 1 deletion clusters/plutus/playground/default.nix
Expand Up @@ -53,7 +53,7 @@ in {
autoscalingGroups = listToAttrs (forEach [
{
region = "eu-central-1";
desiredCapacity = 1;
desiredCapacity = 2;
}
#{
# region = "us-east-2";
Expand Down
37 changes: 31 additions & 6 deletions deploy.cue
Expand Up @@ -7,8 +7,20 @@ import (
)

let fqdn = "plutus.aws.iohkdev.io"
let opsRev = "10dfb90cd37eab05e028e91b054370245ca40924"
let opsRev = "1816240f195e85bf4be3ab4f9ae82aaf0adf8879"
let plutusRev = "0e5520982b48daafac8f49ecbae2d61d1118773c"
let hex = "[0-9a-f]"
let seg = "[-a-zA-Z0-9]"
let flakePath = "github:input-output-hk/\(seg)+\\?rev=\(hex){40}#\(seg)"
let flakes = {
devBox: =~flakePath | *"github:input-output-hk/erc20-ops?rev=\(opsRev)#devbox-entrypoint"
// frontend: =~flakePath | *"github:input-output-hk/erc20-ops?rev=\(opsRev)#frontend-foo-entrypoint"
webGhcServer: =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(opsRev)#web-ghc-server-entrypoint"
"plutus-playground-server": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(opsRev)#plutus-playground-server-entrypoint"
"plutus-playground-client": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(opsRev)#plutus-playground-client-entrypoint"
"marlowe-playground-server": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(opsRev)#marlowe-playground-server-entrypoint"
"marlowe-playground-client": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(opsRev)#marlowe-playground-client-entrypoint"
}

Namespace: [Name=_]: {
vars: {
Expand All @@ -23,12 +35,16 @@ Namespace: [Name=_]: {
#fqdn: fqdn
#opsRev: =~"^\(hex){40}$" | *opsRev
#plutusRev: =~"^\(hex){40}$" | *plutusRev
#flakes: [string]: types.#flake

#flakes: {
devBox: =~flakePath | *"github:input-output-hk/erc20-ops?rev=\(#opsRev)#devbox-entrypoint"
// frontend: =~flakePath | *"github:input-output-hk/erc20-ops?rev=\(#opsRev)#frontend-foo-entrypoint"
webGhcServer: =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#web-ghc-server-entrypoint"
"plutus-playground-server": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#plutus-playground-server-entrypoint"
webGhcServer: =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#web-ghc-server-entrypoint"
"plutus-playground-server": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#plutus-playground-server-entrypoint"
"plutus-playground-client": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#plutus-playground-client-entrypoint"
"marlowe-playground-server": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#marlowe-playground-server-entrypoint"
"marlowe-playground-client": =~flakePath | *"github:input-output-hk/plutus-ops?rev=\(#opsRev)#marlowe-playground-client-entrypoint"
}

#rateLimit: {
Expand All @@ -52,9 +68,18 @@ Namespace: [Name=_]: {
"web-ghc-server": jobDef.#WebGhcServerJob & {
#domain: "web-ghc.\(fqdn)"
}
"plutus-playground-server": jobDef.#PlutusPlaygroundServerJob & {
#domain: "plutus-playground-server.\(fqdn)"
}
"plutus-playground": jobDef.#PlutusPlaygroundJob & {
#domain: "plutus-playground.\(fqdn)"
#variant: "plutus"
#clientFlake: flakes."plutus-playground-client"
#serverFlake: flakes."plutus-playground-server"
}
"marlowe-playground": jobDef.#PlutusPlaygroundJob & {
#domain: "marlowe-playground.\(fqdn)"
#variant: "marlowe"
#clientFlake: flakes."marlowe-playground-client"
#serverFlake: flakes."marlowe-playground-server"
}
// "devbox": jobDef.#DevBoxUnstableJob & {}

//"frontend": jobDef.#FrontendUnstable & {
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Expand Up @@ -4,6 +4,7 @@
inputs = {
utils.url = "github:kreisys/flake-utils";
bitte.url = "github:input-output-hk/bitte/clients-use-vault-agent";
#bitte.url = "path:/home/clever/iohk/bitte";
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
nixpkgs.follows = "bitte/nixpkgs";
bitte-ci.url = "github:input-output-hk/bitte-ci";
Expand Down Expand Up @@ -34,7 +35,7 @@
};

# simpleFlake ignores devShell if we don't specify this.
packages = { checkFmt, checkCue, web-ghc-server-entrypoint, plutus-playground-server-entrypoint, plutus-playground-client-entrypoint }@pkgs: pkgs;
packages = { checkFmt, checkCue, web-ghc-server-entrypoint, plutus-playground-server-entrypoint, plutus-playground-client-entrypoint, marlowe-playground-server-entrypoint, marlowe-playground-client-entrypoint }@pkgs: pkgs;

devShell = { bitteShell, cue }:
(bitteShell {
Expand Down
63 changes: 0 additions & 63 deletions jobs/plutus-playground-server.cue

This file was deleted.

86 changes: 86 additions & 0 deletions jobs/plutus-playground.cue
@@ -0,0 +1,86 @@
package jobs

import (
"github.com/input-output-hk/plutus-ops/pkg/schemas/nomad:types"
"github.com/input-output-hk/plutus-ops/pkg/jobs/tasks:tasks"
)

#PlutusPlaygroundJob: types.#stanza.job & {
#domain: string
#fqdn: string
#flakes: [string]: types.#flake
#hosts: string
#variant: string
#serverFlake: string
#clientFlake: string
#rateLimit: {
average: uint
burst: uint
period: types.#duration
}
#hosts: "`\(#domain)`,`client.\(#fqdn)`"

namespace: string

type: "service"

group: "\(#variant)-playground": {
network: {
mode: "host"
port: {
"\(#variant)-playground-client": { static: 8081 }
"\(#variant)-playground-server": { static: 4003 }
}
}
// Keep count at 1 for now with higher CPU / RAM resources
count: 1

service: "\(namespace)-\(#variant)-playground-client": {
address_mode: "host"
port: "\(#variant)-playground-client"

tags: [
namespace,
"ingress",
"traefik.enable=true",
"traefik.http.routers.\(namespace)-\(#variant)-playground-client.rule=Host(\(#hosts))",
"traefik.http.routers.\(namespace)-\(#variant)-playground-client.entrypoints=https",
"traefik.http.routers.\(namespace)-\(#variant)-playground-client.tls=true",
"traefik.http.routers.\(namespace)-\(#variant)-playground-client.middlewares=\(namespace)-\(#variant)-playground-client-ratelimit@consulcatalog",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-client-ratelimit.ratelimit.average=\(#rateLimit.average)",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-client-ratelimit.ratelimit.burst=\(#rateLimit.burst)",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-client-ratelimit.ratelimit.period=\(#rateLimit.period)",
]
}

service: "\(namespace)-\(#variant)-playground-server": {
address_mode: "host"
port: "\(#variant)-playground-server"

tags: [
namespace,
"ingress",
"traefik.enable=true",
"traefik.http.routers.\(namespace)-\(#variant)-playground-server.rule=Host(\(#hosts)) && PathPrefix(`/api/`)",
"traefik.http.routers.\(namespace)-\(#variant)-playground-server.entrypoints=https",
"traefik.http.routers.\(namespace)-\(#variant)-playground-server.tls=true",
"traefik.http.routers.\(namespace)-\(#variant)-playground-server.middlewares=\(namespace)-web-ghc-server-ratelimit@consulcatalog",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-server-ratelimit.ratelimit.average=\(#rateLimit.average)",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-server-ratelimit.ratelimit.burst=\(#rateLimit.burst)",
"traefik.http.middlewares.\(namespace)-\(#variant)-playground-server-ratelimit.ratelimit.period=\(#rateLimit.period)",
]
}

task: "client": tasks.#SimpleTask & {
#flake: #clientFlake
#namespace: namespace
#memory: 32
}

task: "server": tasks.#SimpleTask & {
#flake: #serverFlake
#namespace: namespace
#memory: 32
}
}
}
3 changes: 2 additions & 1 deletion jobs/tasks/simple-task.cue
Expand Up @@ -8,6 +8,7 @@ import (
#flake: types.#flake

#namespace: string
#memory: uint

driver: "exec"

Expand All @@ -20,7 +21,7 @@ import (

resources: {
cpu: 4000
memory: 5120
memory: #memory
}

config: {
Expand Down
1 change: 1 addition & 0 deletions jobs/web-ghc-server.cue
Expand Up @@ -58,6 +58,7 @@ import (
task: "web-ghc-server": tasks.#SimpleTask & {
#flake: #flakes.webGhcServer
#namespace: namespace
#memory: 4000
}
}
}
9 changes: 7 additions & 2 deletions overlay.nix
Expand Up @@ -124,8 +124,13 @@ in {
web-ghc-server-entrypoint = final.callPackage ./pkgs/web-ghc-server.nix {};

plutus-playground-server = inputs.plutus.packages.x86_64-linux.plutus-playground-server;
plutus-playground-server-entrypoint = final.callPackage ./pkgs/plutus-playground-server.nix {};
plutus-playground-server-entrypoint = final.callPackage ./pkgs/plutus-playground-server.nix { variant = "plutus"; pkg = final.plutus-playground-server; };

plutus-playground-client = inputs.plutus.packages.x86_64-linux.plutus-playground-client;
plutus-playground-client-entrypoint = final.callPackage ./pkgs/plutus-playground-client-entrypoint.nix {};
plutus-playground-client-entrypoint = final.callPackage ./pkgs/plutus-playground-client-entrypoint.nix { root = final.plutus-playground-client; };

marlowe-playground-server = inputs.plutus.packages.x86_64-linux.marlowe-playground-server;
marlowe-playground-server-entrypoint = final.callPackage ./pkgs/plutus-playground-server.nix { variant = "marlowe"; pkg = final.marlowe-playground-server; };
marlowe-playground-client = inputs.plutus.packages.x86_64-linux.marlowe-playground-client;
marlowe-playground-client-entrypoint = final.callPackage ./pkgs/plutus-playground-client-entrypoint.nix { root = final.marlowe-playground-client; };
}
4 changes: 2 additions & 2 deletions pkgs/plutus-playground-client-entrypoint.nix
@@ -1,9 +1,9 @@
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd, plutus-playground-client }:
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd, root }:

let
config = writeText "lighttpd.conf" ''
server.modules = ("mod_deflate")
server.document-root = "${plutus-playground-client}"
server.document-root = "${root}"
server.port = 8081
index-file.names = ("index.html")
mimetype.assign = (
Expand Down
6 changes: 3 additions & 3 deletions pkgs/plutus-playground-server.nix
@@ -1,9 +1,9 @@
{ writeShellScriptBin, plutus-playground-server, symlinkJoin, lib }:
{ writeShellScriptBin, pkg, variant, symlinkJoin, lib }:

let
entrypoint = writeShellScriptBin "entrypoint" ''
export PATH=${lib.makeBinPath [ plutus-playground-server ]}
plutus-playground-server webserver -p 4003
export PATH=${lib.makeBinPath [ pkg ]}
${variant}-playground-server webserver -p 4003
'';
in symlinkJoin {
name = "entrypoint";
Expand Down

0 comments on commit 6c9af23

Please sign in to comment.