This commit is contained in:
2021-08-24 14:35:11 +03:00
parent d8fba9335d
commit 4f37cb59b1
107 changed files with 3941 additions and 66 deletions

49
hello_flask/Dockerfile Executable file
View File

@@ -0,0 +1,49 @@
ARG BUILD_FROM=hassioaddons/base-python:5.2.0
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Copy Python requirements file
COPY requirements.txt /tmp/
COPY app.py /
# Setup base
ARG BUILD_ARCH=amd64
RUN \
apk add --no-cache --virtual .build-dependencies \
g++=9.2.0-r4 \
gcc=9.2.0-r4 \
make=4.2.1-r2 \
\
&& apk add --no-cache \
nginx-mod-http-lua=1.16.1-r6 \
lua-resty-http=0.15-r0 \
nginx=1.16.1-r6 \
cython=0.29.14-r0 \
\
&& pip3 install \
--no-cache-dir \
--prefer-binary \
--find-links "https://wheels.hass.io/alpine-3.11/${BUILD_ARCH}/" \
-r /tmp/requirements.txt \
\
&& find /usr/local \
\( -type d -a -name test -o -name tests -o -name '__pycache__' \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
\
&& apk del --purge .build-dependencies \
&& rm -f -r \
/etc/nginx \
/tmp/*
# Copy data for add-on
COPY run.sh /
COPY requirements.txt /tmp/
# Install requirements for add-on
RUN pip install -r /tmp/requirements.txt
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]

12
hello_flask/app.py Executable file
View File

@@ -0,0 +1,12 @@
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "Hey, we have Flask in a Docker container!"
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")

10
hello_flask/build.json Executable file
View File

@@ -0,0 +1,10 @@
{
"args": {},
"build_from": {
"aarch64": "hassioaddons/base-python-aarch64:5.2.0",
"amd64": "hassioaddons/base-python-amd64:5.2.0",
"armhf": "hassioaddons/base-python-armhf:5.2.0",
"armv7": "hassioaddons/base-python-armv7:5.2.0",
"i386": "hassioaddons/base-python-i386:5.2.0"
}
}

20
hello_flask/config.json Executable file
View File

@@ -0,0 +1,20 @@
{
"name": "Hello flask",
"version": "0.23",
"slug": "hello_flask",
"description": "Hello world flask add-on!",
"arch": [
"armhf",
"armv7",
"aarch64",
"amd64",
"i386"
],
"startup": "before",
"boot": "auto",
"options": {},
"schema": {},
"ports": {
"5000/tcp": 5000
}
}

1
hello_flask/requirements.txt Executable file
View File

@@ -0,0 +1 @@
flask==1.1.2

5
hello_flask/run.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv bashio
echo Running flask hello world
python3 app.py