Compare commits

..

No commits in common. "81ec0779287292341d335cfe12e89f962e8f1046" and "56ff326098c34ffe9f04e34e5422fe21e30cde0e" have entirely different histories.

8 changed files with 14 additions and 47 deletions

View File

@ -1,3 +0,0 @@
ignored:
- DL3018
- DL3059

View File

@ -31,8 +31,3 @@ repos:
entry: test ! -s config/funkos entry: test ! -s config/funkos
language: system language: system
pass_filenames: false pass_filenames: false
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
exclude: 'j2$'

View File

@ -1,13 +1,5 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.20 AS build FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
RUN apk add --no-cache \ RUN apk update && apk add crystal shards yaml-dev openssl-dev zlib-dev libxml2-dev make && apk cache clean
crystal \
shards \
yaml-dev \
openssl-dev \
zlib-dev \
libxml2-dev \
make
RUN rm -rf /var/cache/apk/*
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 Makefile ./
@ -17,22 +9,8 @@ COPY runtimes/ runtimes/
RUN make RUN make
# RUN strip bin/* # RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.20 AS ship FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
RUN apk add --no-cache \ RUN apk update && apk add caddy nss-tools multirun docker openssl zlib yaml pcre2 gc libevent libgcc libxml2 ttyd && apk cache clean
caddy \
nss-tools \
multirun \
docker \
openssl \
zlib \
yaml \
pcre2 \
gc \
libevent \
libgcc \
libxml2 \
ttyd
RUN rm -rf /var/cache/apk/*
# Unprivileged user # Unprivileged user
RUN addgroup -S app && adduser app -S -G app RUN addgroup -S app && adduser app -S -G app
@ -43,6 +21,7 @@ COPY public/ public/
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/
# Mount points for persistent data # Mount points for persistent data
RUN mkdir /secrets /config RUN mkdir /secrets
RUN mkdir /config
CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config config/Caddyfile"] CMD ["/usr/bin/multirun", "-v", "faaso-daemon", "caddy run --config config/Caddyfile"]

View File

@ -4,10 +4,6 @@ shards:
git: https://github.com/sija/backtracer.cr.git git: https://github.com/sija/backtracer.cr.git
version: 1.2.2 version: 1.2.2
base58:
git: https://github.com/crystal-china/base58.cr.git
version: 0.1.0+git.commit.d1150d4a6f086013a475640ad00e561a2fe1082a
cr-config: cr-config:
git: https://github.com/crystal-community/cr-config.git git: https://github.com/crystal-community/cr-config.git
version: 5.1.0+git.commit.5eae3dfbf97da7dfa7c6e64a2a508069948518d3 version: 5.1.0+git.commit.5eae3dfbf97da7dfa7c6e64a2a508069948518d3

View File

@ -15,8 +15,6 @@ crystal: ">= 1.12.2"
license: MIT license: MIT
dependencies: dependencies:
base58:
github: crystal-china/base58.cr
crest: crest:
github: mamantoha/crest github: mamantoha/crest
crinja: crinja:

View File

@ -1,5 +1,3 @@
require "base58"
module Faaso module Faaso
module Commands module Commands
# Build images for one or more funkos from source # Build images for one or more funkos from source
@ -9,7 +7,7 @@ module Faaso
# Create temporary build location # Create temporary build location
funkos.each do |funko| funkos.each do |funko|
tmp_dir = Path.new("tmp", Random.base58(8)) 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.runtime = nil if options["--no-runtime"] funko.runtime = nil if options["--no-runtime"]

View File

@ -1,4 +1,3 @@
require "base58"
require "docr" require "docr"
require "kemal" require "kemal"
require "../funko.cr" require "../funko.cr"
@ -35,7 +34,7 @@ module Funko
# mosquito-cr/mosquito to make it a job queue # mosquito-cr/mosquito to make it a job queue
post "/funkos/build/" do |env| post "/funkos/build/" do |env|
# Create place to build funko # Create place to build funko
tmp_dir = Path.new("tmp", Random.base58(8)) 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
# Expand tarball in there # Expand tarball in there

View File

@ -309,7 +309,7 @@ module Funko
) )
docker_api = Docr::API.new(Docr::Client.new) docker_api = Docr::API.new(Docr::Client.new)
response = docker_api.containers.create(name: "faaso-#{name}-#{Random.base58(6)}", config: conf) response = docker_api.containers.create(name: "faaso-#{name}-#{randstr}", config: conf)
response.@warnings.each { |msg| Log.warn { msg } } response.@warnings.each { |msg| Log.warn { msg } }
docker_api.containers.start(response.@id) if autostart docker_api.containers.start(response.@id) if autostart
response.@id response.@id
@ -349,3 +349,8 @@ module Funko
end end
end end
end end
def randstr(length = 6) : String
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
String.new(Bytes.new(chars.to_slice.sample(length).to_unsafe, length))
end