diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..db3f197 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +.git/ +.gitignore +.github/ +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +*.so +*.egg +*.egg-info/ +dist/ +build/ +*.egg-info/ +.eggs/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.pytest_cache/ +.env +.venv/ +env/ +venv/ +ENV/ +.idea/ +.vscode/ diff --git a/Dockerfile b/Dockerfile index 4323fa7..f0021fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,11 @@ # Build stage FROM python:3.12-slim AS builder +# Define build argument with default value +ARG PORT=8000 +# Make it available as env variable at runtime +ENV OPTILLM_PORT=$PORT + # Set working directory WORKDIR /app @@ -43,8 +48,8 @@ USER appuser # Set environment variables ENV PYTHONUNBUFFERED=1 -# Expose the port the app runs on -EXPOSE 8000 +# Use the ARG in EXPOSE +EXPOSE ${PORT} # Run the application -CMD ["optillm"] +ENTRYPOINT ["python", "optillm.py"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 1ecc209..dd9ef52 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,15 +6,18 @@ services: dockerfile: Dockerfile tags: - optillm:latest + args: + - PORT=${OPTILLM_PORT:-8000} image: optillm:latest container_name: *name hostname: *name ports: - - "8000:8000" + - "${OPTILLM_PORT:-8000}:${OPTILLM_PORT:-8000}" env_file: - .env environment: OPENAI_API_KEY: ${OPENAI_API_KEY:-""} + OPTILLM_PORT: ${OPTILLM_PORT:-8000} # OPTILLM_BASE_URL: ${OPENAI_BASE_URL:-"https://openrouter.ai/api/v1"} # can be set to any OpenAI API compatible endpoint # OPTILLM_API_KEY: ${OPTILLM_API_KEY:-} # optionally sets an API key for Optillm clients # Uncomment and set values for other arguments (prefixed with OPTILLM_) as needed, e.g.: @@ -29,11 +32,10 @@ services: # OPTILLM_RSTAR_C: 1.4 # OPTILLM_N: 1 # OPTILLM_RETURN_FULL_RESPONSE: false - # OPTILLM_PORT: 8000 restart: on-failure stop_grace_period: 2s healthcheck: - test: ["CMD", "curl", "-f", "http://127.0.0.1:8000/health"] + test: ["CMD", "curl", "-f", "http://127.0.0.1:${OPTILLM_PORT:-8000}/health"] interval: 30s timeout: 5s retries: 3 diff --git a/optillm/plugins/readurls_plugin.py b/optillm/plugins/readurls_plugin.py index 0c65d92..e9b5a14 100644 --- a/optillm/plugins/readurls_plugin.py +++ b/optillm/plugins/readurls_plugin.py @@ -25,7 +25,7 @@ def extract_urls(text: str) -> List[str]: def fetch_webpage_content(url: str, max_length: int = 100000) -> str: try: headers = { - 'User-Agent': 'optillm/0.0.20 (https://github.com/codelion/optillm)' + 'User-Agent': 'optillm/0.0.21 (https://github.com/codelion/optillm)' } response = requests.get(url, headers=headers, timeout=10) diff --git a/setup.py b/setup.py index ce51d3a..cb6e81d 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="optillm", - version="0.0.20", + version="0.0.21", packages=find_packages(), py_modules=['optillm'], package_data={