Compare commits
3 Commits
fc55f19660
...
30cfd2e5e6
Author | SHA1 | Date | |
---|---|---|---|
30cfd2e5e6 | |||
f0aa127eed | |||
8efab6b5f8 |
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
build: shard.yml $(wildcard src/**/*) $(runtimes/**/*)
|
build: shard.yml $(wildcard src/**/*) $(runtimes/**/*)
|
||||||
shards build
|
shards build -d --error-trace
|
||||||
cat .rucksack >> bin/faaso
|
cat .rucksack >> bin/faaso
|
||||||
cat .rucksack >> bin/faaso-daemon
|
cat .rucksack >> bin/faaso-daemon
|
||||||
proxy: build
|
proxy: build
|
||||||
|
22
runtimes/flask/Dockerfile.j2
Normal file
22
runtimes/flask/Dockerfile.j2
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade && apk add python3 gcc musl-dev linux-headers python3-dev {{ ship_packages | join(" ") }} {{ devel_packages | join(" ") }} && apk cache clean
|
||||||
|
|
||||||
|
WORKDIR /home/app
|
||||||
|
|
||||||
|
COPY requirements.txt *.py ./
|
||||||
|
RUN python3 -m venv venv
|
||||||
|
RUN venv/bin/pip install uwsgi
|
||||||
|
RUN venv/bin/pip install -r requirements.txt
|
||||||
|
|
||||||
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
|
||||||
|
RUN apk update && apk upgrade && apk add python3 uwsgi curl {{ ship_packages | join " " }} && apk cache clean
|
||||||
|
RUN addgroup -S app && adduser app -S -G app
|
||||||
|
|
||||||
|
WORKDIR /home/app
|
||||||
|
USER app
|
||||||
|
|
||||||
|
COPY --from=build /home/app/ .
|
||||||
|
|
||||||
|
CMD ["venv/bin/uwsgi", "--http", "0.0.0.0:3000", "--master", "-p", "4", "-w", "funko:app"]
|
||||||
|
HEALTHCHECK {{ healthcheck_options }} CMD {{ healthcheck_command }}
|
6
runtimes/flask/main.py
Normal file
6
runtimes/flask/main.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask({{name}})
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
serve(app, host='0.0.0.0', port=5000)
|
7
runtimes/flask/template/funko.py.j2
Normal file
7
runtimes/flask/template/funko.py.j2
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask("{{name}}")
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def handle(req):
|
||||||
|
return "Hello World from Flask!"
|
2
runtimes/flask/template/funko.yml.j2
Normal file
2
runtimes/flask/template/funko.yml.j2
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name: {{ name }}
|
||||||
|
runtime: {{ runtime }}
|
1
runtimes/flask/template/requirements.txt
Normal file
1
runtimes/flask/template/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
flask
|
@ -27,11 +27,12 @@ module Runtime
|
|||||||
elsif File.exists? runtime
|
elsif File.exists? runtime
|
||||||
Log.info { "Using directory #{runtime} as runtime" }
|
Log.info { "Using directory #{runtime} as runtime" }
|
||||||
runtime_base = "#{runtime}"
|
runtime_base = "#{runtime}"
|
||||||
runtime_files = Dir.glob("#{runtime_base}/**/*")
|
runtime_files = Dir.glob("#{runtime_base}/**/*").select { |file| File.file?(file) }
|
||||||
|
runtime_files = runtime_files.map { |file| Path[file].normalize.to_s }
|
||||||
else
|
else
|
||||||
raise Exception.new("Can't find runtime #{runtime}")
|
raise Exception.new("Can't find runtime #{runtime}")
|
||||||
end
|
end
|
||||||
{runtime_base, runtime_files.reject(&.starts_with? "#{runtime_base}template")}
|
{runtime_base, runtime_files.reject(&.starts_with? Path[runtime_base, "template"].normalize.to_s)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.template_files(runtime : String) : {String, Array(String)}
|
def self.template_files(runtime : String) : {String, Array(String)}
|
||||||
@ -44,7 +45,8 @@ module Runtime
|
|||||||
elsif File.exists? runtime
|
elsif File.exists? runtime
|
||||||
Log.info { "Using directory #{runtime} as runtime" }
|
Log.info { "Using directory #{runtime} as runtime" }
|
||||||
template_base = "#{runtime}/template"
|
template_base = "#{runtime}/template"
|
||||||
template_files = Dir.glob("#{template_base}/**/*")
|
template_files = Dir.glob("#{template_base}/**/*").select { |file| File.file?(file) }
|
||||||
|
template_files = template_files.map { |file| Path[file].normalize.to_s }
|
||||||
else
|
else
|
||||||
raise Exception.new("Can't find runtime #{runtime}")
|
raise Exception.new("Can't find runtime #{runtime}")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user