diff --git a/README.md b/README.md index d017b91..bd6f412 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,24 @@ pip install flask WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL+C to quit +``` + +Kubernetes readiness check and load balancer health on /health +``` +http://127.0.0.1:5000/health +``` + +### Building +``` +docker rm biometric-backend-python +docker build -t biometric-backend-python . +docker run -d -p 8081:5000 --name biometric-backend-python biometric-backend-python:latest +docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +763ca7856530 biometric-backend-python:latest "python3 -m flask ru…" 3 seconds ago Up 3 seconds 0.0.0.0:8081->5000/tcp biometric-backend-python + +curl http://127.0.0.1:8081/health +{ "health" : true } ``` diff --git a/src/Dockerfile b/src/Dockerfile new file mode 100644 index 0000000..b650732 --- /dev/null +++ b/src/Dockerfile @@ -0,0 +1,15 @@ +# docker rm biometric-backend-python +# docker build -t biometric-backend-python . +# docker run -d -p 8081:5000 --name biometric-backend-python biometric-backend-python:latest +FROM python:3.10-slim-buster + +WORKDIR /python-server + +# enable when we have dependencies +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY app.py . +#COPY . . + +CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0" ] diff --git a/src/app.py b/src/app.py index 35968a3..bcaae7f 100644 --- a/src/app.py +++ b/src/app.py @@ -13,5 +13,6 @@ def hello_world(): def hello(): return '{ "health" : true }' +# debug only when not running as a container if __name__ == "__main__": app.run(debug=True) diff --git a/src/requirements.txt b/src/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/src/requirements.txt @@ -0,0 +1 @@ +flask