Compare commits

..

No commits in common. "1b2bddf2d2d576e444a1c01fb26056c4f4e50826" and "1d2b44a3bacd7dbfdb706ef26c3c67a817acb2e3" have entirely different histories.

7 changed files with 12 additions and 49 deletions

View File

@ -1,12 +1,14 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
RUN apk update && apk add crystal shards yaml-dev openssl-dev zlib-dev libxml2-dev make && apk cache clean RUN apk update && apk add crystal shards yaml-dev openssl-dev zlib-dev libxml2-dev && apk cache clean
RUN addgroup -S app && adduser app -S -G app RUN addgroup -S app && adduser app -S -G app
WORKDIR /home/app WORKDIR /home/app
COPY shard.yml Makefile ./ COPY shard.yml ./
RUN mkdir src/ RUN mkdir src/
COPY src/ src/ COPY src/ src/
COPY runtimes/ runtimes/ COPY runtimes/ runtimes/
RUN make RUN shards install
RUN shards build -d --error-trace
RUN cat .rucksack >> bin/faaso
# RUN strip bin/* # RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship

View File

@ -1,7 +1,6 @@
build: shard.yml $(wildcard src/**/*) $(runtimes/**/*) build: shard.yml $(wildcard src/**/*) $(runtimes/**/*)
shards build shards build
cat .rucksack >> bin/faaso cat .rucksack >> bin/faaso
cat .rucksack >> bin/faaso-daemon
proxy: build proxy: build
docker build . -t faaso-proxy docker build . -t faaso-proxy
start-proxy: start-proxy:

View File

@ -126,16 +126,6 @@ module Funko
funko.wait_for(1, 1) funko.wait_for(1, 1)
end end
# Delete => scale to 0, remove all containers and images
delete "/funkos/:name/" do |env|
name = env.params.url["name"]
funko = Funko.from_names([name])[0]
funko.scale(0)
funko.wait_for(0, 1)
funko.remove_all_containers
funko.remove_all_images
end
# Return an iframe that shows the container's logs # Return an iframe that shows the container's logs
get "/funkos/terminal/logs/:instance/" do |env| get "/funkos/terminal/logs/:instance/" do |env|
instance = env.params.url["instance"] instance = env.params.url["instance"]

View File

@ -224,32 +224,6 @@ module Funko
end end
end end
# Remove all containers related to this funko
def remove_all_containers
docker_api = Docr::API.new(Docr::Client.new)
docker_api.containers.list(all: true).select { |container|
container.@names.any?(&.starts_with?("/faaso-#{name}-"))
}.each { |container|
begin
docker_api.containers.stop(container.@id) if container.status != "exited"
rescue ex : Docr::Errors::DockerAPIError
Log.error { "#{ex}" } unless ex.status_code == 304 # This just happens
end
docker_api.containers.delete(container.@id)
}
end
# Remove all images related to this funko
def remove_all_images
docker_api = Docr::API.new(Docr::Client.new)
docker_api.images.list.select { |image|
return false if image.@repo_tags.nil?
true if image.@repo_tags.as(Array(String)).any?(&.starts_with?("faaso-#{name}:"))
}.each { |image|
docker_api.images.delete(image.@id)
}
end
# Create a container for this funko # Create a container for this funko
def create_container(autostart : Bool = true) : String def create_container(autostart : Bool = true) : String
# The path to secrets is tricky. On the server it will be in # The path to secrets is tricky. On the server it will be in

View File

@ -1,8 +1,8 @@
require "./faaso.cr" require "./faaso.cr"
require "colorize" require "colorize"
require "docopt" require "docopt"
require "rucksack"
# Log formatter for
struct LogFormat < Log::StaticFormatter struct LogFormat < Log::StaticFormatter
@@colors = { @@colors = {
"FATAL" => :red, "FATAL" => :red,
@ -85,3 +85,8 @@ when .fetch("status", false)
end end
exit(status) exit(status)
# Embed runtimes in the faaso binary using rucksack
{% for name in `find ./runtimes -type f`.split('\n') %}
rucksack({{name}})
{% end %}

View File

@ -91,8 +91,3 @@ module Runtime
end end
end end
end end
# Embed runtimes in the faaso binary using rucksack
{% for name in `find ./runtimes -type f`.split('\n') %}
rucksack({{name}})
{% end %}

View File

@ -39,11 +39,9 @@
<%- if f["scale"].as(String).to_i > 0 -%> <%- if f["scale"].as(String).to_i > 0 -%>
<button disabled hx-get="funkos/<%= f["name"] %>/start">Start</button> <button disabled hx-get="funkos/<%= f["name"] %>/start">Start</button>
<button hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button> <button hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<button disabled hx-delete="funkos/<%= f["name"] %>/" hx-on:htmx:after-request="update_funkos()">Delete</button>
<%- else -%> <%- else -%>
<button hx-get="funkos/<%= f["name"] %>/start" hx-on:htmx:after-request="update_funkos()">Start</button> <button hx-get="funkos/<%= f["name"] %>/start" hx-on:htmx:after-request="update_funkos()">Start</button>
<button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button> <button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<button hx-delete="funkos/<%= f["name"] %>/" hx-on:htmx:after-request="update_funkos()">Delete</button>
<%- end -%> <%- end -%>
<button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button> <button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button>
<%- end -%> <%- end -%>