Skip to content

Commit

Permalink
#1 - dockerize app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems committed Aug 11, 2024
1 parent 98e50c3 commit bc60258
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
```

Expand Down
15 changes: 15 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
1 change: 1 addition & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flask

0 comments on commit bc60258

Please sign in to comment.