From 6296fad068f124e5c31e8d1cf4644c6ef22449bd Mon Sep 17 00:00:00 2001 From: WeijianWWWW Date: Sat, 16 Mar 2024 21:32:05 +0000 Subject: [PATCH 1/3] add docker files --- DockerCommand.txt | 2 ++ Dockerfile | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 DockerCommand.txt create mode 100644 Dockerfile diff --git a/DockerCommand.txt b/DockerCommand.txt new file mode 100644 index 0000000..1cd0ec2 --- /dev/null +++ b/DockerCommand.txt @@ -0,0 +1,2 @@ +docker build ./SwEng-Group-14-SemanticProductLink -t try1 //build images +docker run -d -p 8080:5000 try1 //run the container \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0179a10 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9-alpine +RUN mkdir -p /usr/src/app +COPY ./* /usr/src/app/ +WORKDIR /usr/src/app +RUN pip install Flask flask-cors requests +CMD python backend.py + From 064cbce2d3a170dd45bc2c83c51b6abad7432941 Mon Sep 17 00:00:00 2001 From: WeijianWWWW Date: Sat, 16 Mar 2024 22:03:33 +0000 Subject: [PATCH 2/3] different methods to run locally and run in the docker --- Backend/backend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend/backend.py b/Backend/backend.py index 5e2838f..f36568f 100644 --- a/Backend/backend.py +++ b/Backend/backend.py @@ -97,4 +97,5 @@ def get_task(): return Response(status=400,response={"Unknown error occured"}) if __name__ == "__main__": - app.run(debug=True) + app.run(debug=True, host='0.0.0.0', port=5000) + # app.run(debug=True) From b4dc2bd49afdee3896f0812db0ba6a492944f84b Mon Sep 17 00:00:00 2001 From: WeijianWWWW <123949187+WeijianWWWW@users.noreply.github.com> Date: Sat, 16 Mar 2024 22:06:45 +0000 Subject: [PATCH 3/3] Update DockerCommand.txt --- DockerCommand.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DockerCommand.txt b/DockerCommand.txt index 1cd0ec2..6a6032d 100644 --- a/DockerCommand.txt +++ b/DockerCommand.txt @@ -1,2 +1,2 @@ -docker build ./SwEng-Group-14-SemanticProductLink -t try1 //build images -docker run -d -p 8080:5000 try1 //run the container \ No newline at end of file +docker build ./SwEng-Group-14-SemanticProductLink -t image_name //build images +docker run -d -p 8080:5000 image_name //run the container, the programe will be mapped to local port 8080