Get server URL from FAASO_SERVER
This commit is contained in:
parent
4f2a434e2b
commit
724e14a323
@ -8,12 +8,17 @@ require "uuid"
|
||||
# FIXME: make configurable
|
||||
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
|
||||
# new proxy config
|
||||
get "/" do
|
||||
"Updating routing"
|
||||
patch "/proxy/" do
|
||||
Log.info { "Updating routing" }
|
||||
# Get all the funkos, create routes for them all
|
||||
docker_api = Docr::API.new(Docr::Client.new)
|
||||
containers = docker_api.containers.list(all: true)
|
||||
|
17
src/faaso.cr
17
src/faaso.cr
@ -7,10 +7,7 @@ require "json"
|
||||
require "uuid"
|
||||
|
||||
# API if you just ran faaso-daemon
|
||||
FAASO_API = "http://localhost:3000/"
|
||||
|
||||
# API if you are running the proxy image locally
|
||||
# FAASO_API="http://localhost:8888/admin/"
|
||||
FAASO_SERVER = ENV.fetch("FAASO_SERVER", "http://localhost:3000/")
|
||||
|
||||
# Functions as a Service, Ops!
|
||||
module Faaso
|
||||
@ -80,18 +77,18 @@ module Faaso
|
||||
outf << buf
|
||||
end
|
||||
|
||||
url = "#{FAASO_API}funko/build/"
|
||||
url = "#{FAASO_SERVER}funko/build/"
|
||||
|
||||
begin
|
||||
_response = Crest.post(
|
||||
Log.info { "Uploading funko to #{FAASO_SERVER}" }
|
||||
response = Crest.post(
|
||||
url,
|
||||
{"funko.tgz" => File.open(tmp), "name" => "funko.tgz"},
|
||||
user: "admin", password: "admin"
|
||||
)
|
||||
Log.info { "Build finished successfully." }
|
||||
# body = JSON.parse(_response.body)
|
||||
# puts body["stdout"]
|
||||
# puts body["stderr"]
|
||||
body = JSON.parse(response.body)
|
||||
Log.info { body["stdout"] }
|
||||
rescue ex : Crest::InternalServerError
|
||||
Log.error { "Error building funko #{funko.name} from #{funko.path}" }
|
||||
body = JSON.parse(ex.response.body)
|
||||
@ -129,7 +126,7 @@ module Faaso
|
||||
|
||||
if !local
|
||||
begin
|
||||
response = Crest.get("#{FAASO_API}funko/#{funko.name}/up/",
|
||||
response = Crest.get("#{FAASO_SERVER}funko/#{funko.name}/up/",
|
||||
user: "admin", password: "admin")
|
||||
body = JSON.parse(response.body)
|
||||
Log.info { body["stdout"] }
|
||||
|
@ -6,3 +6,4 @@ Allow 0.0.0.0/0
|
||||
ReverseOnly Yes
|
||||
ReverseMagic Yes
|
||||
ReversePath "/admin/" "http://127.0.0.1:3000/"
|
||||
ReversePath "/faaso/hello/" "http://hello:3000/"
|
Loading…
Reference in New Issue
Block a user