From 84479c786a14b38d54c02335b492639507987ea4 Mon Sep 17 00:00:00 2001 From: Mirko Milovanovic Date: Sat, 15 Feb 2025 15:27:39 +0100 Subject: [PATCH] feat: update Dockerfile to use Debian slim and implement Python virtual environment for dependency management --- Dockerfile | 18 +++++++++++++----- README.md | 6 +----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index c433f14..1314690 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,16 @@ -FROM python:3.13.1-slim-bookworm +FROM debian:bookworm-slim -# Install dependencies +# Install Python +RUN apt-get update && apt-get install -y python3 python3-pip python3-venv + +# Install dependencies with venv +# Create and activate a virtual environment +RUN python3 -m venv /app/venv +ENV PATH="/app/venv/bin:$PATH" + +# Install dependencies with venv COPY requirements.txt /app/requirements.txt -RUN pip install --no-cache-dir -r /app/requirements.txt +RUN /app/venv/bin/pip install --no-cache-dir -r /app/requirements.txt # Install curl RUN apt-get update && apt-get install -y curl @@ -13,7 +21,7 @@ COPY utils/ /app/utils WORKDIR /app # Run the application -CMD ["python", "main.py"] +CMD ["/app/venv/bin/python", "main.py"] # Healthcheck -HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/heartbeat || exit 1 \ No newline at end of file +HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/healthcheck || exit 1 \ No newline at end of file diff --git a/README.md b/README.md index e89a4b6..cf24789 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,7 @@ ufw allow 27107/tcp 4. Start the Docker containers: ```sh - docker compose up --abort-on-container-exit - ``` - or in detached mode: - ```sh - docker compose up -d + docker compose up --abort-on-container-failure ``` The collector will start gathering WebRTC stats from the Selenium container and sending them to the Telegraf service.