From 398bd9ad0653f47c223f5ebcc29522310568bd00 Mon Sep 17 00:00:00 2001 From: Sreenu4Cherry Date: Wed, 11 Jun 2025 19:03:24 +0530 Subject: [PATCH 1/2] updated --- Dockerfile | 22 +++++++++++++++++----- README.md | 8 ++++++++ src/app.py | 4 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1753bad..0f0ec3af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,20 @@ -FROM python:3.13-alpine -LABEL maintainer="lorenz.vanthillo@gmail.com" -COPY . /app +# FROM python:3.13-alpine +# LABEL maintainer="bujjisreenivasulu@gmail.com" +# WORKDIR /app +# COPY . /app +# RUN pip install -r requirements.txt +# ENV APP_PORT=8080 +# EXPOSE 8080 +# ENTRYPOINT ["python"] +# CMD ["src/app.py"] + +FROM python WORKDIR /app +COPY requirements.txt . RUN pip install -r requirements.txt -EXPOSE 8080 +COPY . . +ARG APP_PORT=7070 +ENV APP_PORT ${APP_PORT} +EXPOSE 7070 ENTRYPOINT ["python"] -CMD ["src/app.py"] +CMD ["src/app.py"] \ No newline at end of file diff --git a/README.md b/README.md index 17b868c4..f057da1b 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,12 @@ $ docker inspect -f '{{ .Config.Hostname }}' my-container 6095273a4e9b ``` +### Run below commands to deploy in DOcker Desktop +1. git clone +2. cd +3. Update Docker file +4. docker build --build-arg APP_PORT=7070 -t pyflask:1 . +5. docker run -d -p 8080:8080 pyflask:1 +6. docker rm -f $(docker ps -aq) ; docker rmi -f $(docker images -q) --> !! Careful !! To delete all images & Containers + diff --git a/src/app.py b/src/app.py index c59abfc5..030da21e 100644 --- a/src/app.py +++ b/src/app.py @@ -1,5 +1,6 @@ from flask import Flask, render_template import socket +import os app = Flask(__name__) @@ -15,4 +16,5 @@ def index(): if __name__ == "__main__": - app.run(host="0.0.0.0", port=8080) + port = int(os.environ.get("APP_PORT", 8080)) + app.run(host="0.0.0.0", port=port) From bcbb9a40aed3cbbc0d279b09d941a59d2a56db2e Mon Sep 17 00:00:00 2001 From: Sreenu4Cherry Date: Wed, 11 Jun 2025 19:03:45 +0530 Subject: [PATCH 2/2] updated --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f057da1b..01c1ebae 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,6 @@ $ docker inspect -f '{{ .Config.Hostname }}' my-container 4. docker build --build-arg APP_PORT=7070 -t pyflask:1 . 5. docker run -d -p 8080:8080 pyflask:1 6. docker rm -f $(docker ps -aq) ; docker rmi -f $(docker images -q) --> !! Careful !! To delete all images & Containers +7. git add . ; git commit -m "updated" ; git push origin feature/test