More reorg

This commit is contained in:
Roberto Alsina 2024-07-02 11:27:27 -03:00
parent 5961f8b0a1
commit baf60a1bf7
6 changed files with 79 additions and 16 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/

34
public/index.html Normal file
View File

@ -0,0 +1,34 @@
<head>
<script src="https://cdn.jsdelivr.net/gh/vanjs-org/van/public/van-1.5.0.nomodule.min.js"></script>
<body>
<script>
const { a, div, li, p, ul, span, button } = van.tags;
const funkos = van.state([]);
const funko_list = () => {
console.log("derived");
return div(
p("hello"),
ul(
...funkos.val.map((funko) => {
return li(funko);
})
)
);
};
async function getFunkos() {
for (;;) {
const response = await fetch("funkos/");
funkos.val = await response.json();
console.log(funkos.val);
await new Promise((r) => setTimeout(r, 5000));
}
}
van.add(document.body, funko_list());
getFunkos();
</script>
</body>
</head>

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

@ -0,0 +1,26 @@
require "docr"
require "kemal"
module Funkos
struct Funko
include JSON::Serializable
property name : String
def initialize(@name : String)
end
end
get "/funkos/" do |_|
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}
funkos.to_json
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,9 +1,10 @@
UserName nobody
Port 8888
Listen 0.0.0.0
Timeout 600
Allow 0.0.0.0/0
ReverseOnly Yes
ReverseMagic Yes
ReversePath "/admin/" "http://127.0.0.1:3000/"
ReversePath "/faaso/hello/" "http://hello:3000/"
UserName nobody
Port 8888
Listen 0.0.0.0
Timeout 600
Allow 0.0.0.0/0
ReverseOnly Yes
ReverseMagic Yes
ReversePath "/admin/" "http://127.0.0.1:3000/"
ReversePath "/faaso/hello/" "http://hello:3000/"