diff --git a/.forgejo/workflows/build-push.yml b/.forgejo/workflows/build-push.yml index 673d9cd..e0501f9 100644 --- a/.forgejo/workflows/build-push.yml +++ b/.forgejo/workflows/build-push.yml @@ -5,7 +5,7 @@ on: branches: - main - master - - 'ci/*' + - fix_robustness_dockerize_project tags: - 'v*' diff --git a/Dockerfile b/Dockerfile index 4e9a9a7..639045e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,22 @@ +# Use official lightweight Python base image FROM python:3.11-slim +# Set working directory inside container WORKDIR /app -# Prevent Python from writing .pyc files & buffer stdout/stderr -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PORT=8000 \ - USER_AGENT="Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia)" - +# Install Python dependencies first to leverage Docker layer caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +# Copy application files COPY . . +# Expose default port EXPOSE 8000 +# Set default environment variables +ENV PORT=8000 +ENV USER_AGENT="Phikipathia/1.0 (Wikipedia Philosophy Path Visualizer; https://github.com/tdpeuter/2022ST-project-Phikipathia)" + +# Run Python HTTP server CMD ["python", "server.py"] diff --git a/cgi-bin/scraper.py b/cgi-bin/scraper.py index a7fe6ca..e48883e 100644 --- a/cgi-bin/scraper.py +++ b/cgi-bin/scraper.py @@ -18,7 +18,7 @@ import requests # Default HTTP User-Agent adhering to Wikimedia API policy DEFAULT_USER_AGENT = ( - "Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia; contact@phikipathia.org)" + "Phikipathia/1.0 (https://github.com/tdpeuter/2022ST-project-Phikipathia; contact@phikipathia.org)" ) # Per-request HTTP timeout in seconds diff --git a/docker-compose.yml b/docker-compose.yml index 57d3d5c..37a64e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - "${PORT:-8000}:8000" environment: - PORT=8000 - - USER_AGENT=${USER_AGENT:-Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia)} + - USER_AGENT=${USER_AGENT:-Phikipathia/1.0 (https://github.com/tdpeuter/2022ST-project-Phikipathia)} healthcheck: test: ["CMD-SHELL", "python -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/\")'"] interval: 30s diff --git a/index.html b/index.html index 48ee37d..388cda4 100644 --- a/index.html +++ b/index.html @@ -22,12 +22,7 @@