Fix the docker file path

- add dockerignore
- parameterize port in dockerfile
This commit is contained in:
Asankhaya Sharma
2025-01-03 16:05:28 +08:00
parent 4252dcad1f
commit ac84b638a9
3 changed files with 44 additions and 6 deletions

31
.dockerignore Normal file
View File

@@ -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/

View File

@@ -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"]

View File

@@ -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