diff --git a/runtimes/flask/Dockerfile.j2 b/runtimes/flask/Dockerfile.j2 new file mode 100644 index 0000000..303dd99 --- /dev/null +++ b/runtimes/flask/Dockerfile.j2 @@ -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 }} \ No newline at end of file diff --git a/runtimes/flask/main.py b/runtimes/flask/main.py new file mode 100644 index 0000000..0952f73 --- /dev/null +++ b/runtimes/flask/main.py @@ -0,0 +1,6 @@ +from flask import Flask + +app = Flask({{name}}) + +if __name__ == '__main__': + serve(app, host='0.0.0.0', port=5000) diff --git a/runtimes/flask/template/funko.py.j2 b/runtimes/flask/template/funko.py.j2 new file mode 100644 index 0000000..eeb8c38 --- /dev/null +++ b/runtimes/flask/template/funko.py.j2 @@ -0,0 +1,7 @@ +from flask import Flask + +app = Flask("{{name}}") + +@app.route('/') +def handle(req): + return "Hello World from Flask!" diff --git a/runtimes/flask/template/funko.yml.j2 b/runtimes/flask/template/funko.yml.j2 new file mode 100644 index 0000000..0ab03ef --- /dev/null +++ b/runtimes/flask/template/funko.yml.j2 @@ -0,0 +1,2 @@ +name: {{ name }} +runtime: {{ runtime }} diff --git a/runtimes/flask/template/requirements.txt b/runtimes/flask/template/requirements.txt new file mode 100644 index 0000000..8ab6294 --- /dev/null +++ b/runtimes/flask/template/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file