diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5a80578 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.github +.venv +__pycache__ +*.pyc +.pytest_cache +.mypy_cache +.ruff_cache +somef_outputs +pitfalls_outputs +analysis_results.json +.env diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..18954ae --- /dev/null +++ b/.env.example @@ -0,0 +1,27 @@ +# Optional API tokens. Leave blank to skip a provider. +# Example: github_pat_xxxxxxxxxxxxxxxxxxxx +GITHUB_API_TOKEN= +# Example: glpat-xxxxxxxxxxxxxxxxxxxx +GITLAB_API_TOKEN= +# Example: xxxxxxxxxxxxxxxxxxxx +CODEBERG_TOKEN= +# Example: ATBBxxxxxxxxxxxxxxxxxxxx +BITBUCKET_API_TOKEN= +# Example: user@example.org +BITBUCKET_EMAIL= + +# Classifier model files. Leave blank to use the models installed with somef. +# Example: /usr/local/lib/python3.11/site-packages/somef/models/description.p +SOMEF_DESCRIPTION_MODEL= +# Example: /usr/local/lib/python3.11/site-packages/somef/models/invocation.p +SOMEF_INVOCATION_MODEL= +# Example: /usr/local/lib/python3.11/site-packages/somef/models/installation.p +SOMEF_INSTALLATION_MODEL= +# Example: /usr/local/lib/python3.11/site-packages/somef/models/citation.p +SOMEF_CITATION_MODEL= + +# RDF/base metadata configuration. +# Example: https://w3id.org/okn/i/ +SOMEF_BASE_URI= +# Example: 1000 +SOMEF_DOWNLOAD_LIMIT_MB=1000 diff --git a/.gitignore b/.gitignore index 51416ca..37ff598 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ poetry.lock .env .env.* *.env +!.env.example # Logs *.log @@ -139,4 +140,4 @@ uv.lock results_*/ # Backup directory -BACKUP/ \ No newline at end of file +BACKUP/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9b75e60 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM python:3.11-slim + +# Runtime defaults: no Poetry venv, non-interactive installs, and SoMEF config values. +ENV PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 \ + POETRY_VIRTUALENVS_CREATE=false \ + POETRY_NO_INTERACTION=1 \ + DEBIAN_FRONTEND=noninteractive \ + NLTK_DATA=/usr/local/share/nltk_data \ + SOMEF_CONFIGURATION_FILE=/root/.somef/config.json \ + SOMEF_BASE_URI=https://w3id.org/okn/i/ \ + SOMEF_DOWNLOAD_LIMIT_MB=1000 + +WORKDIR /app + +# System packages needed to install Python packages with native extensions and clone repos. +RUN apt-get update \ + && apt-get install -y --no-install-recommends build-essential git \ + && rm -rf /var/lib/apt/lists/* + +# Install Poetry globally; dependencies will still go into the container Python. +RUN pip install poetry + +# Install project dependencies first to keep Docker layer caching useful. +COPY pyproject.toml poetry.lock ./ +RUN poetry install --only main --no-root --no-ansi + +# Pre-download NLTK resources used by SoMEF so runtime does not configure interactively. +RUN python -m nltk.downloader -d /usr/local/share/nltk_data \ + wordnet omw-1.4 punkt punkt_tab stopwords + +# Copy the application and install only the rsmetacheck package itself. +COPY . . +RUN poetry install --only-root --no-ansi \ + && chmod +x /app/docker-somef-config.sh + +# Configure SoMEF from environment variables, then run rsmetacheck through Poetry. +ENTRYPOINT ["/app/docker-somef-config.sh"] +CMD ["rsmetacheck", "--help"] diff --git a/docker-somef-config.sh b/docker-somef-config.sh new file mode 100644 index 0000000..e8edec0 --- /dev/null +++ b/docker-somef-config.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +echo "configuring somef..." +printf "%s\n" \ + "${GITHUB_API_TOKEN:-}" \ + "${GITLAB_API_TOKEN:-}" \ + "${CODEBERG_TOKEN:-}" \ + "${BITBUCKET_API_TOKEN:-}" \ + "${BITBUCKET_EMAIL:-}" \ + "${SOMEF_DESCRIPTION_MODEL:-}" \ + "${SOMEF_INVOCATION_MODEL:-}" \ + "${SOMEF_INSTALLATION_MODEL:-}" \ + "${SOMEF_CITATION_MODEL:-}" \ + "${SOMEF_BASE_URI:-}" \ + "${SOMEF_DOWNLOAD_LIMIT_MB:-1000}" \ + | somef configure + +exec "$@"