Compare commits

..

5 Commits

7 changed files with 15 additions and 34 deletions

View File

@ -2,23 +2,13 @@
http_port 8888
https_port 8887
local_certs
admin off
}
http://localhost:8888 {
http://mindy:8888 {
handle_path /admin/terminal/* {
reverse_proxy /* http://127.0.0.1:7681
}
handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000
}
handle_path /faaso/hello/* {
reverse_proxy /* http://faaso-hello-8t3u59:3000 http://faaso-hello-5epnbg:3000 http://faaso-hello-zt5j6g:3000 {
health_uri /ping
fail_duration 30s
}
}
}
}

View File

@ -10,7 +10,7 @@ RUN shards build -d --error-trace
RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
RUN apk update && apk add caddy multirun docker openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
RUN apk update && apk add caddy nss-tools multirun docker openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
# Unprivileged user
RUN addgroup -S app && adduser app -S -G app

View File

@ -1,7 +1,7 @@
build: shard.yml $(wildcard src/**/*cr)
shards build
proxy: build
docker build . -t faaso-proxy --no-cache
docker build . -t faaso-proxy
start-proxy:
docker run --name faaso-proxy-one --rm --network=faaso-net -v /var/run/docker.sock:/var/run/docker.sock -v secrets:/home/app/secrets -p 8888:8888 faaso-proxy

View File

@ -125,24 +125,16 @@ module Funko
end
# Return an iframe that shows the container's logs
get "/funkos/:name/terminal/logs" do |env|
name = env.params.url["name"]
funko = Funko.from_names([name])[0]
# FIXME: Just getting the 1st one for now, it
# may not even be running
container_name = funko.containers.map { |c| c.@names[0] }[0]
Terminal.start_terminal(["docker", "logs", "-f", container_name.to_s])
get "/funkos/terminal/logs/:instance/" do |env|
instance = env.params.url["instance"]
Terminal.start_terminal(["docker", "logs", "-f", instance])
"<iframe src='terminal/' width='100%' height='100%'></iframe>"
end
# Get an iframe with a shell into the container
get "/funkos/:name/terminal/shell" do |env|
name = env.params.url["name"]
funko = Funko.from_names([name])[0]
# FIXME: Just getting the 1st one for now, it
# may not even be running
container_name = funko.containers.map { |c| c.@names[0] }[0].lstrip("/")
Terminal.start_terminal(["docker", "exec", "-ti", container_name, "/bin/sh"], readonly: false)
get "/funkos/terminal/shell/:instance/" do |env|
instance = env.params.url["instance"]
Terminal.start_terminal(["docker", "exec", "-ti", instance, "/bin/sh"], readonly: false)
"<iframe src='terminal/' width='100%' height='100%'></iframe>"
end

View File

@ -13,7 +13,7 @@ require "uuid"
basic_auth "admin", "admin"
get "/" do |env|
env.redirect "index.html"
env.redirect "/index.html"
end
Kemal.run

View File

@ -26,10 +26,9 @@ module Proxy
http_port 8888
https_port 8887
local_certs
admin off
}
http://localhost:8888 {
http://mindy:8888 {
handle_path /admin/terminal/* {
reverse_proxy /* http://127.0.0.1:7681
}
@ -65,7 +64,7 @@ CONFIG
file << config
end
# Reload config
Process.run(command: "/usr/bin/killall", args: ["-USR1", "caddy"])
Process.run(command: "caddy", args: ["reload", "--config", "Caddyfile"])
@@current_config = config
end
config

View File

@ -23,8 +23,8 @@
<%- end -%>
</td>
<td>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/logs/">Logs</button>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/shell/">Shell</button>
<button hx-target="#terminal" hx-get="funkos/terminal/logs/<%= c.@names[0].lstrip("/") %>/">Logs</button>
<button hx-target="#terminal" hx-get="funkos/terminal/shell/<%= c.@names[0].lstrip("/") %>/">Shell</button>
</td>
</tr>
<%- end -%>