diff --git a/Dockerfile b/Dockerfile index 9529d7b..4675fed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,12 +17,11 @@ RUN addgroup -S app && adduser app -S -G app WORKDIR /home/app RUN mkdir /home/app/tmp && chown app /home/app/tmp - -RUN mkdir runtimes public COPY public/ public/ -COPY Caddyfile ./ COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/ +# Mount points for persistent data RUN mkdir /secrets +RUN mkdir /config -CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config Caddyfile"] +CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config config/Caddyfile"] diff --git a/Makefile b/Makefile index bd9217c..e2c6c81 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,14 @@ build: shard.yml $(wildcard src/**/*) $(runtimes/**/*) proxy: build docker build . -t faaso-proxy start-proxy: - docker run --name faaso-proxy-one --rm --network=faaso-net --env-file=proxy.env -e FAASO_SECRET_PATH=${PWD}/secrets -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/secrets:/home/app/secrets -p 8888:8888 faaso-proxy + docker run --name faaso-proxy-one \ + --rm --network=faaso-net \ + --env-file=proxy.env \ + -e FAASO_SECRET_PATH=${PWD}/secrets \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v ${PWD}/secrets:/home/app/secrets \ + -v ${PWD}/config:/home/app/config \ + -p 8888:8888 faaso-proxy .PHONY: build proxy-image start-proxy diff --git a/Caddyfile b/config/Caddyfile similarity index 53% rename from Caddyfile rename to config/Caddyfile index 29669d7..292451c 100644 --- a/Caddyfile +++ b/config/Caddyfile @@ -6,7 +6,7 @@ http://*:8888 { basicauth /admin/* { - admin {$FAASO_PASSWORD} + admin {$HTTP_BASIC_AUTH_PASSWORD} } handle_path /admin/terminal/* { @@ -15,4 +15,13 @@ http://*:8888 { handle_path /admin/* { reverse_proxy /* http://127.0.0.1:3000 } -} + + + handle_path /faaso/myfunko/* { + reverse_proxy /* http://faaso-myfunko-kyfo2v:3000 { + health_uri /ping + fail_duration 30s + } + } + +} \ No newline at end of file diff --git a/src/daemon/proxy.cr b/src/daemon/proxy.cr index 94bfd2d..9e5fd2c 100644 --- a/src/daemon/proxy.cr +++ b/src/daemon/proxy.cr @@ -2,8 +2,10 @@ require "docr" require "./funko.cr" require "kemal" + module Proxy - @@current_config = File.read("Caddyfile") + CADDY_CONFIG_PATH = "config/Caddyfile" + @@current_config = File.read(CADDY_CONFIG_PATH) # Get current proxy config get "/proxy/" do @@ -64,7 +66,7 @@ CONFIG if @@current_config != config Log.info { "Updating proxy config" } - File.open("Caddyfile", "w") do |file| + File.open(CADDY_CONFIG_PATH, "w") do |file| file << config end # Reload config diff --git a/tinyproxy.conf b/tinyproxy.conf deleted file mode 100644 index ca31fc9..0000000 --- a/tinyproxy.conf +++ /dev/null @@ -1,12 +0,0 @@ - -User nobody -Group nogroup -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 "/admin/terminal" "http://127.0.0.1:7681" - ReversePath "/faaso/hello/" "http://hello-d89veq:3000/" \ No newline at end of file