working?
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 1m14s

This commit is contained in:
Karl 2025-07-14 15:48:05 +01:00
parent be33cdd1da
commit 2a49e280c2
3 changed files with 53 additions and 25 deletions

View File

@ -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"]

View File

@ -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
Werkzeug==3.1.3

View File

@ -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()"
/opt/venv/bin/gunicorn --bind 0.0.0.0:$PORT "ktvmanager.main:create_app"