Working terminal/shell/logs but container selection is broken
This commit is contained in:
parent
56e59ae4a0
commit
05438d13cf
@ -1,8 +1,6 @@
|
||||
|
||||
{
|
||||
https_port 8888
|
||||
http_port 8887
|
||||
local_certs
|
||||
}
|
||||
|
||||
localhost:8888 {
|
||||
@ -13,6 +11,3 @@ localhost:8888 {
|
||||
reverse_proxy /* http://127.0.0.1:3000
|
||||
}
|
||||
}
|
||||
handle_path /faaso/hello/* {
|
||||
reverse_proxy /* http://hello-d89veq:3000
|
||||
}
|
||||
|
@ -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 openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
|
||||
RUN apk update && apk add caddy 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
|
||||
|
@ -32,6 +32,7 @@
|
||||
<tbody id="funko-list">
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="terminal" style="resize: vertical; overflow: auto;"></div>
|
||||
</main>
|
||||
<script>
|
||||
update_funkos = function () {
|
||||
|
@ -124,6 +124,28 @@ module Funko
|
||||
funko.wait_for(1, 1)
|
||||
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])
|
||||
"<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)
|
||||
"<iframe src='terminal/' width='100%' height='100%'></iframe>"
|
||||
end
|
||||
|
||||
# Helper to run faaso locally and get a response back
|
||||
def run_faaso(args : Array(String))
|
||||
Log.info { "Running faaso [#{args.join(", ")}, -l]" }
|
||||
|
@ -47,7 +47,7 @@ localhost:8888 {
|
||||
handle_path /faaso/#{funko.split("-")[0]}/* {
|
||||
reverse_proxy /* http://#{funko}:3000
|
||||
}
|
||||
)}.join("\n") +"}"
|
||||
) }.join("\n") + "}"
|
||||
|
||||
if @@current_config != config
|
||||
File.open("Caddyfile", "w") do |file|
|
||||
|
@ -3,16 +3,19 @@ module Terminal
|
||||
|
||||
@@terminal_process : Process | Nil = nil
|
||||
|
||||
def start_terminal(_args = ["sh"], readonly = false)
|
||||
def start_terminal(_args = ["sh"], readonly = true)
|
||||
args = ["-p", "7681", "-c", "admin:admin", "-o"]
|
||||
args += ["-W"] unless readonly
|
||||
args += _args
|
||||
# We have a process there, kill it
|
||||
@@terminal_process.as(Process).terminate if !@@terminal_process.nil?
|
||||
begin
|
||||
@@terminal_process.as(Process).terminate if !@@terminal_process.nil?
|
||||
rescue e : RuntimeError
|
||||
Log.error { "Error terminating terminal process: #{e.message}" }
|
||||
end
|
||||
@@terminal_process = Process.new(
|
||||
command: "/usr/bin/ttyd",
|
||||
args: args)
|
||||
Log.info {"Terminal started on port 7681"}
|
||||
Log.info { "Terminal started on port 7681" }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,12 +10,13 @@
|
||||
<%- if f["scale"].to_i > 0 -%>
|
||||
<button disabled hx-get="funkos/<%= f["name"] %>/start">Start</button>
|
||||
<button hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
|
||||
<button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button>
|
||||
<%- else -%>
|
||||
<button hx-get="funkos/<%= f["name"] %>/start" hx-on:htmx:after-request="update_funkos()">Start</button>
|
||||
<button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
|
||||
<button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button>
|
||||
<%- end -%>
|
||||
<button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button>
|
||||
<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>
|
||||
<%- end -%>
|
||||
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator">
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user