Fix rucksack and bugs
This commit is contained in:
parent
2eb20aa09b
commit
2644cd4b86
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
http://*:8888 {
|
http://*:8888 {
|
||||||
basicauth /admin/* {
|
basicauth /admin/* {
|
||||||
# admin $2a$14$C35905PxPzICAZKc/O9jYOS7ipZNPBtrndja8Yu3bvs/UujckryHS
|
|
||||||
admin {$HTTP_BASIC_AUTH_PASSWORD}
|
admin {$HTTP_BASIC_AUTH_PASSWORD}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@ WORKDIR /home/app
|
|||||||
COPY shard.yml ./
|
COPY shard.yml ./
|
||||||
RUN mkdir src/
|
RUN mkdir src/
|
||||||
COPY src/ src/
|
COPY src/ src/
|
||||||
|
COPY runtimes/ runtimes/
|
||||||
RUN shards install
|
RUN shards install
|
||||||
RUN shards build -d --error-trace
|
RUN shards build -d --error-trace
|
||||||
RUN strip bin/*
|
# RUN strip bin/*
|
||||||
|
|
||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
|
||||||
RUN apk update && apk add caddy nss-tools multirun docker openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
|
RUN apk update && apk add caddy nss-tools multirun docker openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
|
||||||
@ -17,7 +18,6 @@ RUN addgroup -S app && adduser app -S -G app
|
|||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
RUN mkdir runtimes public
|
RUN mkdir runtimes public
|
||||||
COPY runtimes/ runtimes/
|
|
||||||
COPY public/ public/
|
COPY public/ public/
|
||||||
COPY Caddyfile ./
|
COPY Caddyfile ./
|
||||||
COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/
|
COPY --from=build /home/app/bin/faaso-daemon /home/app/bin/faaso /usr/bin/
|
||||||
|
3
Makefile
3
Makefile
@ -1,5 +1,6 @@
|
|||||||
build: shard.yml $(wildcard src/**/*cr)
|
build: shard.yml $(wildcard src/**/*) $(runtimes/**/*)
|
||||||
shards build
|
shards build
|
||||||
|
cat .rucksack >> bin/faaso
|
||||||
proxy: build
|
proxy: build
|
||||||
docker build . -t faaso-proxy
|
docker build . -t faaso-proxy
|
||||||
start-proxy:
|
start-proxy:
|
||||||
|
@ -4,26 +4,30 @@ module Faaso
|
|||||||
struct Build
|
struct Build
|
||||||
def run(options, folders : Array(String)) : Int32
|
def run(options, folders : Array(String)) : Int32
|
||||||
funkos = Funko::Funko.from_paths(folders)
|
funkos = Funko::Funko.from_paths(folders)
|
||||||
|
|
||||||
if options["--local"]
|
|
||||||
funkos.each do |funko|
|
|
||||||
# Create temporary build location
|
# Create temporary build location
|
||||||
|
|
||||||
|
funkos.each do |funko|
|
||||||
tmp_dir = Path.new("tmp", UUID.random.to_s)
|
tmp_dir = Path.new("tmp", UUID.random.to_s)
|
||||||
Dir.mkdir_p(tmp_dir) unless File.exists? tmp_dir
|
Dir.mkdir_p(tmp_dir) unless File.exists? tmp_dir
|
||||||
funko.prepare_build tmp_dir
|
|
||||||
|
|
||||||
|
funko.runtime = nil if options["--no-runtime"]
|
||||||
|
|
||||||
|
funko.prepare_build(path: tmp_dir)
|
||||||
|
if options["--local"]
|
||||||
|
funkos.each do |funko|
|
||||||
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
||||||
funko.build tmp_dir
|
funko.build tmp_dir
|
||||||
end
|
end
|
||||||
else # Running against a server
|
else # Running against a server
|
||||||
funkos.each do |funko|
|
|
||||||
# Create a tarball for the funko
|
# Create a tarball for the funko
|
||||||
buf = IO::Memory.new
|
buf = IO::Memory.new
|
||||||
Compress::Gzip::Writer.open(buf) do |gzip|
|
Compress::Gzip::Writer.open(buf) do |gzip|
|
||||||
Crystar::Writer.open(gzip) do |tw|
|
Crystar::Writer.open(gzip) do |tw|
|
||||||
Dir.glob("#{funko.path}/**/*").each do |path|
|
Log.debug { "Adding files to tarball" }
|
||||||
|
Dir.glob("#{tmp_dir}/**/*").each do |path|
|
||||||
next unless File.file? path
|
next unless File.file? path
|
||||||
rel_path = Path[path].relative_to funko.path
|
rel_path = Path[path].relative_to tmp_dir
|
||||||
|
Log.debug { "Adding #{rel_path}" }
|
||||||
file_info = File.info(path)
|
file_info = File.info(path)
|
||||||
hdr = Crystar::Header.new(
|
hdr = Crystar::Header.new(
|
||||||
name: rel_path.to_s,
|
name: rel_path.to_s,
|
||||||
@ -52,12 +56,9 @@ module Faaso
|
|||||||
)
|
)
|
||||||
Log.info { "Build finished successfully." }
|
Log.info { "Build finished successfully." }
|
||||||
body = JSON.parse(response.body)
|
body = JSON.parse(response.body)
|
||||||
Log.info { body["stdout"] }
|
Log.info { body["output"] }
|
||||||
rescue ex : Crest::InternalServerError
|
rescue ex : Crest::InternalServerError
|
||||||
Log.error { "Error building funko #{funko.name} from #{funko.path}" }
|
Log.error(exception: ex) { "Error building funko #{funko.name} from #{funko.path}" }
|
||||||
body = JSON.parse(ex.response.body)
|
|
||||||
Log.info { body["stdout"] }
|
|
||||||
Log.error { body["stderr"] }
|
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,6 +56,8 @@ module Funko
|
|||||||
Compress::Gzip::Reader.open(file) do |gzip|
|
Compress::Gzip::Reader.open(file) do |gzip|
|
||||||
Crystar::Reader.open(gzip) do |tar|
|
Crystar::Reader.open(gzip) do |tar|
|
||||||
tar.each_entry do |entry|
|
tar.each_entry do |entry|
|
||||||
|
dst = Path.new(tmp_dir, entry.name)
|
||||||
|
Dir.mkdir_p dst.dirname
|
||||||
File.open(Path.new(tmp_dir, entry.name), "w") do |dst|
|
File.open(Path.new(tmp_dir, entry.name), "w") do |dst|
|
||||||
IO.copy entry.io, dst
|
IO.copy entry.io, dst
|
||||||
end
|
end
|
||||||
@ -64,7 +66,7 @@ module Funko
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Build the thing
|
# Build the thing
|
||||||
response = run_faaso(["build", tmp_dir.to_s])
|
response = run_faaso(["build", tmp_dir.to_s, "--no-runtime"])
|
||||||
|
|
||||||
if response["exit_code"] != 0
|
if response["exit_code"] != 0
|
||||||
halt env, status_code: 500, response: response.to_json
|
halt env, status_code: 500, response: response.to_json
|
||||||
@ -148,6 +150,7 @@ module Funko
|
|||||||
output: output,
|
output: output,
|
||||||
error: output,
|
error: output,
|
||||||
)
|
)
|
||||||
|
Log.debug { "faaso output: #{output.to_s}" }
|
||||||
result = {
|
result = {
|
||||||
"exit_code" => status.exit_code,
|
"exit_code" => status.exit_code,
|
||||||
"output" => output.to_s,
|
"output" => output.to_s,
|
||||||
|
@ -151,6 +151,7 @@ module Funko
|
|||||||
|
|
||||||
# Build image using docker in path previously prepared using `prepare_build`
|
# Build image using docker in path previously prepared using `prepare_build`
|
||||||
def build(path : Path)
|
def build(path : Path)
|
||||||
|
Log.info { "Building image for #{name} in #{path}" }
|
||||||
docker_api = Docr::API.new(Docr::Client.new)
|
docker_api = Docr::API.new(Docr::Client.new)
|
||||||
docker_api.images.build(
|
docker_api.images.build(
|
||||||
context: path.to_s,
|
context: path.to_s,
|
||||||
|
@ -46,7 +46,7 @@ doc = <<-DOC
|
|||||||
FaaSO CLI tool.
|
FaaSO CLI tool.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
faaso build FOLDER ... [-v <level>] [-l]
|
faaso build FOLDER ... [-v <level>] [-l] [--no-runtime]
|
||||||
faaso export SOURCE DESTINATION [-v <level>]
|
faaso export SOURCE DESTINATION [-v <level>]
|
||||||
faaso new -r runtime FOLDER [-v <level>]
|
faaso new -r runtime FOLDER [-v <level>]
|
||||||
faaso scale FUNKO [SCALE] [-v <level>] [-l]
|
faaso scale FUNKO [SCALE] [-v <level>] [-l]
|
||||||
@ -59,6 +59,7 @@ Options:
|
|||||||
-d --delete Delete
|
-d --delete Delete
|
||||||
-h --help Show this screen
|
-h --help Show this screen
|
||||||
-l --local Run commands locally instead of against a FaaSO server
|
-l --local Run commands locally instead of against a FaaSO server
|
||||||
|
--no-runtime Don't merge a runtime into the funko
|
||||||
-r runtime Runtime for the new funko (use -r list for examples)
|
-r runtime Runtime for the new funko (use -r list for examples)
|
||||||
-v level Control the logging verbosity, 0 to 5 [default: 3]
|
-v level Control the logging verbosity, 0 to 5 [default: 3]
|
||||||
DOC
|
DOC
|
||||||
|
Loading…
Reference in New Issue
Block a user