Compare commits
No commits in common. "d0e2a1a494b7c772b97b37929d6fccacbd03c22d" and "05438d13cf1d92c6d706c282103e59dcb02d1bf5" have entirely different histories.
d0e2a1a494
...
05438d13cf
@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
http_port 8888
|
https_port 8888
|
||||||
https_port 8887
|
http_port 8887
|
||||||
local_certs
|
|
||||||
admin off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
http://localhost:8888 {
|
localhost: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
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,6 @@ COPY Caddyfile ./
|
|||||||
COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/
|
COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/
|
||||||
|
|
||||||
RUN mkdir /secrets
|
RUN mkdir /secrets
|
||||||
|
RUN echo "sarasa" > /secrets/sarlanga
|
||||||
|
|
||||||
CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config Caddyfile"]
|
CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config Caddyfile"]
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
module Faaso
|
|
||||||
module Commands
|
|
||||||
struct Secret
|
|
||||||
def local(options, funko, name, secret)
|
|
||||||
if options["--add"]
|
|
||||||
dst_dir = "secrets/#{funko}"
|
|
||||||
Dir.mkdir_p(dst_dir) unless Dir.exists?(dst_dir)
|
|
||||||
File.write("#{dst_dir}/#{name}", secret)
|
|
||||||
elsif options["--delete"]
|
|
||||||
File.delete("secrets/#{funko}/#{name}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def remote(options, funko, name, secret)
|
|
||||||
if options["--add"]
|
|
||||||
Crest.post(
|
|
||||||
"#{FAASO_SERVER}secrets/",
|
|
||||||
{
|
|
||||||
"funko" => funko,
|
|
||||||
"name" => name,
|
|
||||||
"value" => secret,
|
|
||||||
}, user: "admin", password: "admin")
|
|
||||||
Log.info { "Secret created" }
|
|
||||||
elsif options["--delete"]
|
|
||||||
Crest.delete(
|
|
||||||
"#{FAASO_SERVER}secrets/#{funko}/#{name}",
|
|
||||||
user: "admin", password: "admin")
|
|
||||||
end
|
|
||||||
rescue ex : Crest::RequestFailed
|
|
||||||
Log.error { "Error #{ex.response.status_code}" }
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
|
|
||||||
def run(options, funko, name)
|
|
||||||
if options["--add"]
|
|
||||||
Log.info { "Enter the secret, end with Ctrl-D" } if STDIN.tty?
|
|
||||||
secret = STDIN.gets_to_end
|
|
||||||
else
|
|
||||||
secret = ""
|
|
||||||
end
|
|
||||||
|
|
||||||
if options["--local"]
|
|
||||||
return local(options, funko, name, secret)
|
|
||||||
end
|
|
||||||
remote(options, funko, name, secret)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -20,46 +20,36 @@ module Proxy
|
|||||||
def self.update_proxy_config
|
def self.update_proxy_config
|
||||||
docker_api = Docr::API.new(Docr::Client.new)
|
docker_api = Docr::API.new(Docr::Client.new)
|
||||||
containers = docker_api.containers.list(all: true)
|
containers = docker_api.containers.list(all: true)
|
||||||
config = <<-CONFIG
|
|
||||||
|
funkos = [] of String
|
||||||
|
containers.each { |container|
|
||||||
|
names = container.names.select &.starts_with? "/faaso-"
|
||||||
|
next if names.empty?
|
||||||
|
funkos << names[0][7..]
|
||||||
|
}
|
||||||
|
funkos.sort!
|
||||||
|
|
||||||
|
config = %(
|
||||||
{
|
{
|
||||||
http_port 8888
|
https_port 8888
|
||||||
https_port 8887
|
http_port 8887
|
||||||
local_certs
|
local_certs
|
||||||
admin off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
http://localhost:8888 {
|
localhost: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
|
||||||
}
|
}
|
||||||
|
) + funkos.map { |funko| %(
|
||||||
|
handle_path /faaso/#{funko.split("-")[0]}/* {
|
||||||
CONFIG
|
reverse_proxy /* http://#{funko}:3000
|
||||||
|
}
|
||||||
funkos = Funko::Funko.from_docker
|
) }.join("\n") + "}"
|
||||||
funkos.each do |funko|
|
|
||||||
next if funko.name == "proxy"
|
|
||||||
containers = funko.containers
|
|
||||||
next if containers.empty?
|
|
||||||
funko_urls = containers.map { |container|
|
|
||||||
"http://#{container.names[0].lstrip("/")}:3000"
|
|
||||||
}
|
|
||||||
config += %(
|
|
||||||
handle_path /faaso/#{funko.name}/* {
|
|
||||||
reverse_proxy /* #{funko_urls.join(" ")} {
|
|
||||||
health_uri /ping
|
|
||||||
fail_duration 30s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
config += "\n}"
|
|
||||||
|
|
||||||
if @@current_config != config
|
if @@current_config != config
|
||||||
Log.info { "Updating proxy config" }
|
|
||||||
File.open("Caddyfile", "w") do |file|
|
File.open("Caddyfile", "w") do |file|
|
||||||
file << config
|
file << config
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user