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..01c1ebae 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,13 @@ $ 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 +7. git add . ; git commit -m "updated" ; git push origin feature/test + 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)