45 lines
1.3 KiB
Docker
45 lines
1.3 KiB
Docker
# Use an official Python runtime as a parent image
|
|
FROM python:3.9-slim
|
|
|
|
# Set environment variable to prevent Python from buffering its outputs
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /app
|
|
|
|
# Copy the local requirements file to the container
|
|
COPY requirements.txt /app/requirements.txt
|
|
|
|
# Install Selenium and its required drivers
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
wget \
|
|
curl \
|
|
unzip \
|
|
build-essential \
|
|
libsqlite3-dev \
|
|
sqlite3 \
|
|
chromium \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install the required Python packages
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Set up Chrome WebDriver for Selenium
|
|
RUN wget -q -O /app/chromedriver.zip https://storage.googleapis.com/chrome-for-testing-public/129.0.6668.70/linux64/chromedriver-linux64.zip && \
|
|
unzip /app/chromedriver.zip && \
|
|
mv /app/chromedriver-linux64/chromedriver /app && \
|
|
chmod +x /app/chromedriver && \
|
|
rm -rf /app/chromedriver.zip /app/chromedriver-linux64
|
|
|
|
# Set environment variables for Chrome and ChromeDriver
|
|
ENV PATH=/app:$PATH
|
|
ENV DISPLAY=:99
|
|
|
|
# Copy the rest of the application code to the container
|
|
COPY . /app
|
|
|
|
# Start the bot
|
|
CMD ["python", "main.py"]
|