From 2a49e280c266de1dd66266150bc59f142ba0a21d Mon Sep 17 00:00:00 2001 From: Karl Date: Mon, 14 Jul 2025 15:48:05 +0100 Subject: [PATCH] working? --- dockerfile | 54 ++++++++++++++++++++++++++++++------------------ requirements.txt | 22 ++++++++++++++++---- run_docker.sh | 2 +- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/dockerfile b/dockerfile index 71e3682..7c4d098 100644 --- a/dockerfile +++ b/dockerfile @@ -1,31 +1,45 @@ -FROM python:3.11-slim-bookworm +# ---- Builder Stage ---- +FROM python:3.10-slim-bookworm as builder -RUN apt-get update && apt-get install -y --no-install-recommends \ - git \ - libglib2.0-0 \ - libsm6 \ - libxrender1 \ - libxext6 \ - libgomp1 \ - libgl1 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +# Install git for fetching git-based dependencies +RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* +# Create a virtual environment +RUN python -m venv /opt/venv + +# Activate the virtual environment +ENV PATH="/opt/venv/bin:$PATH" + +# Copy requirements and install dependencies WORKDIR /app - COPY requirements.txt . -RUN pip install --no-cache-dir requests stem -RUN pip install --no-cache-dir git+https://github.com/karl0ss/requests_tor.git@ae1e85abb3bb2c25f431bd031c6d881986c626f6 +RUN pip install --no-cache-dir wheel requests==2.32.3 stem==1.8.2 RUN pip install --no-cache-dir --no-build-isolation -r requirements.txt +# ---- Final Stage ---- +FROM python:3.10-slim-bookworm + +# Set working directory +WORKDIR /app + +# Copy virtual environment from builder stage +COPY --from=builder /opt/venv /opt/venv + +# Activate the virtual environment +ENV PATH="/opt/venv/bin:$PATH" +ENV FLASK_ENV=production +ENV FLASK_APP=ktvmanager.main:create_app + +# Copy application code COPY . . - +# Handle versioning ARG VERSION -RUN echo $VERSION > VERSION +RUN if [ -n "$VERSION" ]; then echo $VERSION > VERSION; fi +# Debugging step +RUN ls -l /opt/venv/lib/python3.10/site-packages/ + +# Make run script executable and run the application EXPOSE 3001 - -ENV FLASK_ENV=production -RUN chmod +x run_docker.sh -CMD ["./run_docker.sh"] +CMD ["/opt/venv/bin/python", "-m", "flask", "run", "--host=0.0.0.0", "--port=3001"] diff --git a/requirements.txt b/requirements.txt index 2ee7b48..60eae41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,20 +1,34 @@ +blinker==1.9.0 Brotli==1.1.0 certifi==2025.4.26 cffi==1.17.1 charset-normalizer==3.4.2 +click==8.2.1 cryptography==44.0.3 +exceptiongroup==1.3.0 +Flask==3.1.1 idna==3.10 +iniconfig==2.1.0 +itsdangerous==2.2.0 +Jinja2==3.1.6 +MarkupSafe==3.0.2 mysql-connector-python==9.3.0 +packaging==25.0 +pluggy==1.6.0 pycparser==2.22 +pycryptodome==3.23.0 +pycryptodomex==3.23.0 pyeasyencrypt==0.1.0 +Pygments==2.19.2 +PyJWT==2.10.1 pyodbc==5.2.0 PySocks==1.7.1 +pytest==8.4.1 python-dotenv==1.1.0 requests==2.32.3 requests-tor @ git+https://github.com/karl0ss/requests_tor.git@ae1e85abb3bb2c25f431bd031c6d881986c626f6 stem==1.8.2 +tomli==2.2.1 +typing_extensions==4.14.1 urllib3==2.4.0 -gunicorn -Flask -PyJWT -pycryptodome==3.20.0 \ No newline at end of file +Werkzeug==3.1.3 diff --git a/run_docker.sh b/run_docker.sh index a9b5844..245b5f6 100644 --- a/run_docker.sh +++ b/run_docker.sh @@ -7,4 +7,4 @@ fi PORT=$(python -c "from ktvmanager.config import ProductionConfig; print(ProductionConfig.PORT)") echo "Starting in production mode on port $PORT..." -gunicorn --bind 0.0.0.0:$PORT "ktvmanager.main:create_app()" \ No newline at end of file +/opt/venv/bin/gunicorn --bind 0.0.0.0:$PORT "ktvmanager.main:create_app" \ No newline at end of file