Make things work enough for video demo

This commit is contained in:
Roberto Alsina 2024-07-05 13:25:40 -03:00
parent 0ffd562cca
commit d5efd6b301
3 changed files with 18 additions and 9 deletions

View File

@ -8,6 +8,7 @@ COPY src/ src/
COPY runtimes/ runtimes/
RUN shards install
RUN shards build -d --error-trace
RUN cat .rucksack >> bin/faaso
# RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
@ -16,6 +17,8 @@ RUN apk update && apk add caddy nss-tools multirun docker openssl zlib yaml pcre
# Unprivileged user
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/

View File

@ -4,7 +4,7 @@ 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 -v /var/run/docker.sock:/var/run/docker.sock -v 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 secrets:/home/app/secrets -p 8888:8888 faaso-proxy
.PHONY: build proxy-image start-proxy

View File

@ -80,12 +80,7 @@ module Funko
# Get the number of running instances of this funko
def scale
docker_api = Docr::API.new(Docr::Client.new)
docker_api.containers.list.select { |container|
container.@state == "running"
}.count { |container|
container.@names.any?(&.starts_with?("/faaso-#{name}-"))
}
containers.size
end
# Set the number of running instances of this funko
@ -153,9 +148,12 @@ module Funko
def build(path : Path)
Log.info { "Building image for #{name} in #{path}" }
docker_api = Docr::API.new(Docr::Client.new)
tags = ["faaso-#{name}:latest"]
Log.info { " Tags: #{tags}" }
docker_api.images.build(
context: path.to_s,
tags: ["faaso-#{name}:latest"]) { |x| Log.info { x } }
tags: tags,
no_cache: true) { |x| Log.info { x } }
end
def images
@ -232,7 +230,15 @@ module Funko
# Create a container for this funko
def create_container(autostart : Bool = true) : String
secrets_mount = "#{Dir.current}/secrets/#{name}"
# The path to secrets is tricky. On the server it will be in
# ./secrets/ BUT when you call on the Docker API you need to
# pass the path in the HOST SYSTEM WHERE DOCKER IS RUNNING
# so allow for a FAASO_SECRET_PATH override which will
# be set for the proxy container
secrets_mount = ENV.fetch(
"FAASO_SECRET_PATH",
"#{Dir.current}/secrets/#{name}"
)
Dir.mkdir_p(secrets_mount)
conf = Docr::Types::CreateContainerConfig.new(
image: "faaso-#{name}:latest",