From f396c98cbed4428c1ee78a440cb61951cf54d599 Mon Sep 17 00:00:00 2001 From: Cipher Vance Date: Tue, 9 Sep 2025 08:31:16 -0500 Subject: [PATCH] chore(docker): include .env, fix port, install dotenv --- .dockerignore | 2 +- Dockerfile | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index ce46172..d9b625e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,7 @@ __pycache__/ *.py[cod] *.log -.env +!.env venv/ .venv/ dist/ diff --git a/Dockerfile b/Dockerfile index 1468378..c72dff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,17 +16,17 @@ RUN python -m pip install --upgrade pip && \ pip wheel --no-deps -r requirements.txt -w /wheels && \ pip wheel --no-deps gunicorn -w /wheels - FROM python:3.10-slim AS runtime ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ - PORT=8000 \ + PORT=5000 \ WSGI_MODULE=server:app \ GUNICORN_WORKERS=2 \ GUNICORN_THREADS=4 \ - GUNICORN_TIMEOUT=60 + GUNICORN_TIMEOUT=60 \ + FLASK_APP=server.py WORKDIR /app @@ -35,13 +35,19 @@ RUN groupadd -g 10001 app && useradd -m -u 10001 -g app app COPY --from=builder /wheels /wheels RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels +# Install python-dotenv if not already in requirements.txt +RUN pip install python-dotenv + USER app COPY --chown=app:app . . -EXPOSE 8000 +# Copy .env file specifically +COPY --chown=app:app .env .env + +EXPOSE 5000 HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ - CMD python -c "import os,socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1', int(os.getenv('PORT', '8000')))); s.close()" + CMD python -c "import os,socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1', int(os.getenv('PORT', '5000')))); s.close()" CMD ["sh", "-c", "exec gunicorn $WSGI_MODULE --bind=0.0.0.0:$PORT --workers=$GUNICORN_WORKERS --threads=$GUNICORN_THREADS --timeout=$GUNICORN_TIMEOUT --access-logfile=- --error-logfile=- --keep-alive=5"] \ No newline at end of file