From 07537d1cb064388e3238819622ba7ced193c1cef Mon Sep 17 00:00:00 2001 From: Daniel Husar Date: Wed, 29 May 2024 18:59:56 +0200 Subject: [PATCH 1/4] Add docker --- Dockerfile | 19 +++++++++++++++++++ README.md | 4 ++++ run.py | 10 +++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 Dockerfile mode change 100755 => 100644 run.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0f292b31 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# start by pulling the python image +FROM python:3.11.9-slim-bullseye + +# copy the requirements file into the image +COPY ./requirements.txt /app/requirements.txt + +# switch working directory +WORKDIR /app + +# install the dependencies and packages in the requirements file +RUN pip install -r requirements.txt + +# copy every content from the local file to the image +COPY . /app + +# configure the container to run in an executed manner +ENTRYPOINT [ "python" ] + +CMD ["run.py", "--docker"] diff --git a/README.md b/README.md index 064236ab..d5c9ccf0 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,10 @@ For a list of code examples that use the Web Forms API, see the [How-to guides o **Note:** You will need to alias the python command to run Python 3 or use `python3 run.py` 1. Open a browser to http://localhost:3000 +### Installation steps with docker +1. `docker image build -t docusign .` +1. `docker run --name docusign_python -p 3000:3000 -d docusign` + ### Installation steps for JWT Grant authentication **Note:** If you downloaded this code using [Quickstart](https://developers.docusign.com/docs/esign-rest-api/quickstart/) from the Docusign Developer Center, skip step 4 as it was automatically performed for you. diff --git a/run.py b/run.py old mode 100755 new mode 100644 index 8c7e5943..0ee4c9f1 --- a/run.py +++ b/run.py @@ -2,17 +2,21 @@ from app import app from flask_session import Session import os +import sys + +host = "0.0.0.0" if "--docker" in sys.argv else "localhost" +port = int(os.environ.get("PORT", 3000)) if os.environ.get("DEBUG", False) == "True": app.config["DEBUG"] = True app.config['SESSION_TYPE'] = 'filesystem' sess = Session() sess.init_app(app) - port = int(os.environ.get("PORT", 3000)) - app.run(host="localhost", port=3000, debug=True) + port = int(os.environ.get("PORT", port)) + app.run(host=host, port=port, debug=True) else: app.config['SESSION_TYPE'] = 'filesystem' sess = Session() sess.init_app(app) - app.run(host="localhost", port=3000, extra_files="api_type.py") + app.run(host=host, port=port, extra_files="api_type.py") From 23af9d05bcae72c1475142e785744000105c6d17 Mon Sep 17 00:00:00 2001 From: Daniel Husar Date: Wed, 29 May 2024 19:02:21 +0200 Subject: [PATCH 2/4] tweak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5c9ccf0..5d6cf308 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ For a list of code examples that use the Web Forms API, see the [How-to guides o ### Installation steps with docker 1. `docker image build -t docusign .` -1. `docker run --name docusign_python -p 3000:3000 -d docusign` +1. `docker run --name docusign_python -p 3000:3000 -d docusign` ### Installation steps for JWT Grant authentication From e92b6e623bc68e8e6854b18c41affe6e0437b67a Mon Sep 17 00:00:00 2001 From: Daniel Husar Date: Wed, 29 May 2024 19:21:29 +0200 Subject: [PATCH 3/4] remove dup port --- requirements.txt | 2 +- run.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 360c6c2e..c46b5d28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ python-dateutil==2.8.2 python-dotenv==0.21.0 requests>=2.28.2 requests-oauthlib==1.1.0 -six==1.13.0 +six>1.13.0 urllib3>=1.26.14 virtualenv==20.21.0 virtualenv-clone==0.5.7 diff --git a/run.py b/run.py index 0ee4c9f1..eeb04907 100644 --- a/run.py +++ b/run.py @@ -12,7 +12,6 @@ app.config['SESSION_TYPE'] = 'filesystem' sess = Session() sess.init_app(app) - port = int(os.environ.get("PORT", port)) app.run(host=host, port=port, debug=True) else: app.config['SESSION_TYPE'] = 'filesystem' From cbc7dc5f911266e586a964e49682a7b828de602c Mon Sep 17 00:00:00 2001 From: Daniel Husar Date: Wed, 29 May 2024 20:49:46 +0200 Subject: [PATCH 4/4] revert six change --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c46b5d28..360c6c2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ python-dateutil==2.8.2 python-dotenv==0.21.0 requests>=2.28.2 requests-oauthlib==1.1.0 -six>1.13.0 +six==1.13.0 urllib3>=1.26.14 virtualenv==20.21.0 virtualenv-clone==0.5.7