feat: update Dockerfile to use Debian slim and implement Python virtual environment for dependency management
All checks were successful
Build and Push Docker Image / build (push) Successful in 4m20s

This commit is contained in:
2025-02-15 15:27:39 +01:00
parent 5636d92474
commit 84479c786a
2 changed files with 14 additions and 10 deletions

View File

@@ -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 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 # Install curl
RUN apt-get update && apt-get install -y curl RUN apt-get update && apt-get install -y curl
@@ -13,7 +21,7 @@ COPY utils/ /app/utils
WORKDIR /app WORKDIR /app
# Run the application # Run the application
CMD ["python", "main.py"] CMD ["/app/venv/bin/python", "main.py"]
# Healthcheck # Healthcheck
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/heartbeat || exit 1 HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/healthcheck || exit 1

View File

@@ -48,11 +48,7 @@ ufw allow 27107/tcp
4. Start the Docker containers: 4. Start the Docker containers:
```sh ```sh
docker compose up --abort-on-container-exit docker compose up --abort-on-container-failure
```
or in detached mode:
```sh
docker compose up -d
``` ```
The collector will start gathering WebRTC stats from the Selenium container and sending them to the Telegraf service. The collector will start gathering WebRTC stats from the Selenium container and sending them to the Telegraf service.