From a73f6555597b59c998d57c0bc5d1750cea58a0a2 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Sun, 18 Jun 2023 18:11:00 -0400 Subject: [PATCH] docker --- dennis/.dockerignore | 7 +++++++ dennis/.gitignore | 1 + dennis/Dockerfile | 7 +++++++ dennis/build | 16 ++++++++++++++++ dennis/main.py | 2 +- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 dennis/.dockerignore create mode 100644 dennis/Dockerfile create mode 100755 dennis/build diff --git a/dennis/.dockerignore b/dennis/.dockerignore new file mode 100644 index 0000000..14f3e6a --- /dev/null +++ b/dennis/.dockerignore @@ -0,0 +1,7 @@ +bin/ +dist/ +lib/ +pyvenv.cfg + +build +run diff --git a/dennis/.gitignore b/dennis/.gitignore index 83fa1a9..f834aec 100644 --- a/dennis/.gitignore +++ b/dennis/.gitignore @@ -1,4 +1,5 @@ bin/ +dist/ lib/ __pycache__/ pyvenv.cfg diff --git a/dennis/Dockerfile b/dennis/Dockerfile new file mode 100644 index 0000000..4f71146 --- /dev/null +++ b/dennis/Dockerfile @@ -0,0 +1,7 @@ +# syntax=docker/dockerfile:experimental + +FROM python +COPY . . +RUN python -m ensurepip && pip install --upgrade --no-cache-dir -r requirements.txt +CMD ["python3", "main.py"] +EXPOSE 9696 diff --git a/dennis/build b/dennis/build new file mode 100755 index 0000000..854c5ff --- /dev/null +++ b/dennis/build @@ -0,0 +1,16 @@ +#!/bin/bash + +NAME="dennis" +FILE_PATH="dist/$NAME.tar.gz" + +if [ ! -d "dist" ]; then + mkdir dist +fi + +if [ -f $FILE_PATH ]; then + rm $FILE_PATH +fi + +docker build -t $NAME . + +echo "Compressing..." && docker save $NAME | pigz > $FILE_PATH diff --git a/dennis/main.py b/dennis/main.py index 16b24f2..d16e847 100644 --- a/dennis/main.py +++ b/dennis/main.py @@ -3,4 +3,4 @@ import multiprocessing if __name__ == "__main__": multiprocessing.freeze_support() - uvicorn.run('src.dennis:api', host="127.0.0.1", port=9696, reload=True) + uvicorn.run('src.dennis:api', host='0.0.0.0', port=9696, reload=False)