From 2c1107ca5d26a811d77bc5c5deccf0766830dffe Mon Sep 17 00:00:00 2001 From: Michael Saunby Date: Mon, 12 Jun 2023 20:37:44 +0100 Subject: [PATCH] no nginx - try me with https --- Dockerfile | 11 ++++++----- Dockerfile-nginx | 20 ++++++++++++++++++++ app/main.py | 2 +- requirements.txt | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 Dockerfile-nginx diff --git a/Dockerfile b/Dockerfile index 9955207..17d3a14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -# See https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/ -FROM tiangolo/uwsgi-nginx-flask:python3.11 +# Base Image +FROM python:3.11-slim-bullseye # Build args ARG VERSION # Working Directory -# WORKDIR /app +WORKDIR /app # Install packages from requirements.txt COPY requirements.txt /app/requirements.txt @@ -15,6 +15,7 @@ RUN pip install --no-cache-dir --upgrade pip &&\ # Copy source code to working directory COPY ./app /app -# Default env vars -ENV PORT=80 +# Default env vars and command. +ENV PORT=5000 ENV VERSION=$VERSION +CMD ["python", "/app/main.py"] diff --git a/Dockerfile-nginx b/Dockerfile-nginx new file mode 100644 index 0000000..9955207 --- /dev/null +++ b/Dockerfile-nginx @@ -0,0 +1,20 @@ +# See https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/ +FROM tiangolo/uwsgi-nginx-flask:python3.11 + +# Build args +ARG VERSION + +# Working Directory +# WORKDIR /app + +# Install packages from requirements.txt +COPY requirements.txt /app/requirements.txt +RUN pip install --no-cache-dir --upgrade pip &&\ + pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt + +# Copy source code to working directory +COPY ./app /app + +# Default env vars +ENV PORT=80 +ENV VERSION=$VERSION diff --git a/app/main.py b/app/main.py index dbd7b3b..e011ca0 100644 --- a/app/main.py +++ b/app/main.py @@ -10,4 +10,4 @@ def home(): if __name__ == "__main__": port = os.environ.get('PORT') - app.run(host='0.0.0.0', port=port) \ No newline at end of file + app.run(host='0.0.0.0', port=port, ssl_context='adhoc') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fd9774e..a519116 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ wheel flask +pyopenssl