Compare commits

...

3 Commits

Author SHA1 Message Date
4371444fa4 Embryo of web frontend 2024-07-02 12:40:47 -03:00
baf60a1bf7 More reorg 2024-07-02 11:27:27 -03:00
5961f8b0a1 Add UserName to tinyproxy conf 2024-07-02 10:40:36 -03:00
8 changed files with 74 additions and 8 deletions

View File

@ -1,5 +1,5 @@
# This configuration file was generated by `ameba --gen-config`
# on 2024-07-01 13:11:14 UTC using Ameba version 1.6.1.
# on 2024-07-01 18:57:31 UTC using Ameba version 1.6.1.
# The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base.
@ -10,9 +10,9 @@ Documentation/DocumentationAdmonition:
Timezone: UTC
Excluded:
- src/faaso.cr
- src/daemon.cr
- src/daemon/main.cr
- src/daemon/secrets.cr
- src/funko.cr
- src/daemon-secrets.cr
- spec/faaso_spec.cr
Admonitions:
- TODO

View File

@ -4,7 +4,7 @@ RUN addgroup -S app && adduser app -S -G app
WORKDIR /home/app
COPY shard.yml ./
RUN mkdir src/
COPY src/* src/
COPY src/ src/
RUN shards install
RUN shards build -d --error-trace
RUN strip bin/*
@ -16,8 +16,9 @@ RUN apk add tinyproxy multirun openssl zlib yaml pcre2 gc libevent libgcc libxml
RUN addgroup -S app && adduser app -S -G app
WORKDIR /home/app
RUN mkdir runtimes
COPY runtimes/* ./runtimes/
RUN mkdir runtimes public
COPY runtimes/ runtimes/
COPY public/ public/
COPY tinyproxy.conf ./
COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/

25
public/index.html Normal file
View File

@ -0,0 +1,25 @@
<head>
<link rel="stylesheet" href="https://matcha.mizu.sh/matcha.css" />
<script src="https://unpkg.com/htmx.org@2.0.0"></script>
<body>
<script>
async function getFunkos() {
const response = await fetch("funkos/");
funkos = await response.json();
console.log(funkos);
}
getFunkos();
</script>
<button hx-get="funkos/?format=html" hx-target="#funko-list">Update</button>
<table>
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>Action</th>
</tr>
<tbody id="funko-list">
</tbody>
</thead>
</body>
</head>

31
src/daemon/funkos.cr Normal file
View File

@ -0,0 +1,31 @@
require "docr"
require "kemal"
module Funkos
struct Funko
include JSON::Serializable
property name : String
def initialize(@name : String)
end
end
get "/funkos/" do |env|
docker_api = Docr::API.new(Docr::Client.new)
containers = docker_api.containers.list(all: true)
funkos = [] of Funko
containers.each { |container|
names = container.names.select &.starts_with? "/faaso-"
next if names.empty?
funkos << Funko.new(name: names[0][7..])
}
funkos.sort! { |a, b| a.name <=> b.name }
if env.params.query.fetch("format", "json") == "html"
render "src/views/funkos.ecr"
else
funkos.to_json
end
end
end

View File

@ -1,5 +1,6 @@
require "./secrets.cr"
require "./funkos.cr"
require "./proxyconf.cr"
require "./secrets.cr"
require "compress/gzip"
require "crystar"
require "docr"

View File

@ -1,3 +1,4 @@
require "docr"
require "kemal"
module Proxy
@ -29,6 +30,7 @@ module Proxy
funkos.sort!
config = %(
UserName nobody
Port 8888
Listen 0.0.0.0
Timeout 600

5
src/views/funkos.ecr Normal file
View File

@ -0,0 +1,5 @@
<%- funkos.each do |funko| -%>
<td><%= funko.name %></td>
<td>sarasa</td>
<td><button>DOSTUFF</button></td>
<%- end -%>

View File

@ -1,4 +1,5 @@
UserName nobody
Port 8888
Listen 0.0.0.0
Timeout 600
@ -6,4 +7,4 @@
ReverseOnly Yes
ReverseMagic Yes
ReversePath "/admin/" "http://127.0.0.1:3000/"
ReversePath "/faaso/hello/" "http://hello:3000/"