Compare commits

...

5 Commits

7 changed files with 15 additions and 34 deletions

View File

@ -2,23 +2,13 @@
http_port 8888 http_port 8888
https_port 8887 https_port 8887
local_certs local_certs
admin off
} }
http://localhost:8888 { http://mindy:8888 {
handle_path /admin/terminal/* { handle_path /admin/terminal/* {
reverse_proxy /* http://127.0.0.1:7681 reverse_proxy /* http://127.0.0.1:7681
} }
handle_path /admin/* { handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000 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/* RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship 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 # Unprivileged user
RUN addgroup -S app && adduser app -S -G app RUN addgroup -S app && adduser app -S -G app

View File

@ -1,7 +1,7 @@
build: shard.yml $(wildcard src/**/*cr) build: shard.yml $(wildcard src/**/*cr)
shards build shards build
proxy: build proxy: build
docker build . -t faaso-proxy --no-cache docker build . -t faaso-proxy
start-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 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 end
# Return an iframe that shows the container's logs # Return an iframe that shows the container's logs
get "/funkos/:name/terminal/logs" do |env| get "/funkos/terminal/logs/:instance/" do |env|
name = env.params.url["name"] instance = env.params.url["instance"]
funko = Funko.from_names([name])[0] Terminal.start_terminal(["docker", "logs", "-f", instance])
# 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])
"<iframe src='terminal/' width='100%' height='100%'></iframe>" "<iframe src='terminal/' width='100%' height='100%'></iframe>"
end end
# Get an iframe with a shell into the container # Get an iframe with a shell into the container
get "/funkos/:name/terminal/shell" do |env| get "/funkos/terminal/shell/:instance/" do |env|
name = env.params.url["name"] instance = env.params.url["instance"]
funko = Funko.from_names([name])[0] Terminal.start_terminal(["docker", "exec", "-ti", instance, "/bin/sh"], readonly: false)
# 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)
"<iframe src='terminal/' width='100%' height='100%'></iframe>" "<iframe src='terminal/' width='100%' height='100%'></iframe>"
end end

View File

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

View File

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

View File

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