Get server URL from FAASO_SERVER

This commit is contained in:
Roberto Alsina 2024-06-30 18:05:02 -03:00
parent 4f2a434e2b
commit 724e14a323
3 changed files with 16 additions and 13 deletions

View File

@ -8,12 +8,17 @@ require "uuid"
# FIXME: make configurable # FIXME: make configurable
basic_auth "admin", "admin" basic_auth "admin", "admin"
current_config = "" current_config = File.read("tinyproxy.conf")
# Get current proxy config
get "/proxy/" do
current_config
end
# Bump proxy config to current docker state, returns # Bump proxy config to current docker state, returns
# new proxy config # new proxy config
get "/" do patch "/proxy/" do
"Updating routing" Log.info { "Updating routing" }
# Get all the funkos, create routes for them all # Get all the funkos, create routes for them all
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)

View File

@ -7,10 +7,7 @@ require "json"
require "uuid" require "uuid"
# API if you just ran faaso-daemon # API if you just ran faaso-daemon
FAASO_API = "http://localhost:3000/" FAASO_SERVER = ENV.fetch("FAASO_SERVER", "http://localhost:3000/")
# API if you are running the proxy image locally
# FAASO_API="http://localhost:8888/admin/"
# Functions as a Service, Ops! # Functions as a Service, Ops!
module Faaso module Faaso
@ -80,18 +77,18 @@ module Faaso
outf << buf outf << buf
end end
url = "#{FAASO_API}funko/build/" url = "#{FAASO_SERVER}funko/build/"
begin begin
_response = Crest.post( Log.info { "Uploading funko to #{FAASO_SERVER}" }
response = Crest.post(
url, url,
{"funko.tgz" => File.open(tmp), "name" => "funko.tgz"}, {"funko.tgz" => File.open(tmp), "name" => "funko.tgz"},
user: "admin", password: "admin" user: "admin", password: "admin"
) )
Log.info { "Build finished successfully." } Log.info { "Build finished successfully." }
# body = JSON.parse(_response.body) body = JSON.parse(response.body)
# puts body["stdout"] Log.info { body["stdout"] }
# puts body["stderr"]
rescue ex : Crest::InternalServerError rescue ex : Crest::InternalServerError
Log.error { "Error building funko #{funko.name} from #{funko.path}" } Log.error { "Error building funko #{funko.name} from #{funko.path}" }
body = JSON.parse(ex.response.body) body = JSON.parse(ex.response.body)
@ -129,7 +126,7 @@ module Faaso
if !local if !local
begin begin
response = Crest.get("#{FAASO_API}funko/#{funko.name}/up/", response = Crest.get("#{FAASO_SERVER}funko/#{funko.name}/up/",
user: "admin", password: "admin") user: "admin", password: "admin")
body = JSON.parse(response.body) body = JSON.parse(response.body)
Log.info { body["stdout"] } Log.info { body["stdout"] }

View File

@ -6,3 +6,4 @@ Allow 0.0.0.0/0
ReverseOnly Yes ReverseOnly Yes
ReverseMagic Yes ReverseMagic Yes
ReversePath "/admin/" "http://127.0.0.1:3000/" ReversePath "/admin/" "http://127.0.0.1:3000/"
ReversePath "/faaso/hello/" "http://hello:3000/"