diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f292b3 --- /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 064236a..5d6cf30 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 8c7e594..eeb0490 --- a/run.py +++ b/run.py @@ -2,17 +2,20 @@ 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) + 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")