chore: modernize Docker setup with Python 3.13 and env_file integration

- Upgraded base image to python:3.13-slim.
- Optimized Docker layer caching (requirements first).
- Integrated env_file: .env in docker-compose.yml for consistency.
- Added build-essential to support potential C-extension libraries.
This commit is contained in:
Reynov Christian
2025-12-31 15:02:35 +08:00
parent f0b5a07545
commit 5df683e2ce
2 changed files with 27 additions and 23 deletions
+21 -17
View File
@@ -1,30 +1,34 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Use Python 3.13 for best performance and compatibility with QuantumBotX v2.1.0
FROM python:3.13-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install system dependencies (build-essential for math/financial libraries)
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
git \
&& rm -rf /var/lib/apt/lists/*
# Install system dependencies (git only for potential future use)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Copy only requirements first to leverage Docker cache
COPY requirements.txt .
# Upgrade pip and install dependencies with a generous timeout
ENV PIP_DEFAULT_TIMEOUT=120
# Upgrade pip and install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy pandas_ta stub for compatibility
COPY pandas_ta_stub /app/pandas_ta_stub
# Install dependencies and pandas_ta stub
RUN python -m pip install --upgrade pip && \
pip install /app/pandas_ta_stub && \
pip install --no-cache-dir -r requirements-docker.txt
# Copy the rest of the application
COPY . .
# Set environment variables
ENV FLASK_APP=run.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV BROKER_TYPE=CCXT
# Default to CCXT in Docker since MT5 doesn't run on Linux easily
ENV PYTHONUNBUFFERED=1
# Run run.py when the container launches
# Default environment to Production when using Docker
ENV FLASK_ENV=production
# Run the application
CMD ["python", "run.py"]
+6 -6
View File
@@ -1,18 +1,18 @@
# Docker Compose for QuantumBotX (no version key needed)
services:
quantumbotx:
build: .
container_name: quantumbotx_bot
ports:
- "5000:5000"
volumes:
- .:/app
- ./instance:/app/instance # Persist database
- ./logs:/app/logs # Persist logs
- ./instance:/app/instance # Persist database (SQLite)
- ./logs:/app/logs # Persist trade logs
env_file:
- .env # Gunakan konfigurasi terpusat dari .env Anda
environment:
- FLASK_ENV=development
- BROKER_TYPE=CCXT
- EXCHANGE_ID=binance
- FLASK_HOST=0.0.0.0
# - API_KEY=your_api_key
# - API_SECRET=your_api_secret
- PYTHONUNBUFFERED=1
restart: unless-stopped