-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
add openssl in apk install in runtime stage in dockerfile.non_root #13168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+132
−71
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,66 @@ | ||
| services: | ||
| litellm: | ||
| build: | ||
| context: . | ||
| args: | ||
| target: runtime | ||
| image: ghcr.io/berriai/litellm:main-stable | ||
| ######################################### | ||
| ## Uncomment these lines to start proxy with a config.yaml file ## | ||
| # volumes: | ||
| # - ./config.yaml:/app/config.yaml <<- this is missing in the docker-compose file currently | ||
| # command: | ||
| # - "--config=/app/config.yaml" | ||
| ############################################## | ||
| ports: | ||
| - "4000:4000" # Map the container port to the host, change the host port if necessary | ||
| environment: | ||
| DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm" | ||
| STORE_MODEL_IN_DB: "True" # allows adding models to proxy via UI | ||
| env_file: | ||
| - .env # Load local .env file | ||
| depends_on: | ||
| - db # Indicates that this service depends on the 'db' service, ensuring 'db' starts first | ||
| healthcheck: # Defines the health check configuration for the container | ||
| test: [ "CMD-SHELL", "wget --no-verbose --tries=1 http://localhost:4000/health/liveliness || exit 1" ] # Command to execute for health check | ||
| interval: 30s # Perform health check every 30 seconds | ||
| timeout: 10s # Health check command times out after 10 seconds | ||
| retries: 3 # Retry up to 3 times if health check fails | ||
| start_period: 40s # Wait 40 seconds after container start before beginning health checks | ||
|
|
||
| db: | ||
| image: postgres:16 | ||
| restart: always | ||
| container_name: litellm_db | ||
| environment: | ||
| POSTGRES_DB: litellm | ||
| POSTGRES_USER: llmproxy | ||
| POSTGRES_PASSWORD: dbpassword9090 | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data # Persists Postgres data across container restarts | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -d litellm -U llmproxy"] | ||
| interval: 1s | ||
| timeout: 5s | ||
| retries: 10 | ||
|
|
||
| prometheus: | ||
| image: prom/prometheus | ||
| volumes: | ||
| - prometheus_data:/prometheus | ||
| - ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
| ports: | ||
| - "9090:9090" | ||
| command: | ||
| - "--config.file=/etc/prometheus/prometheus.yml" | ||
| - "--storage.tsdb.path=/prometheus" | ||
| - "--storage.tsdb.retention.time=15d" | ||
| restart: always | ||
|
|
||
| volumes: | ||
| prometheus_data: | ||
| driver: local | ||
| postgres_data: | ||
| name: litellm_postgres_data # Named volume for Postgres data persistence | ||
|
|
||
| services: | ||
| litellm: | ||
| build: | ||
| context: . | ||
| args: | ||
| target: runtime | ||
| image: ghcr.io/berriai/litellm:main-stable | ||
| ######################################### | ||
| ## Uncomment these lines to start proxy with a config.yaml file ## | ||
| # volumes: | ||
| # - ./config.yaml:/app/config.yaml <<- this is missing in the docker-compose file currently | ||
| # command: | ||
| # - "--config=/app/config.yaml" | ||
| ############################################## | ||
| ports: | ||
| - "4000:4000" # Map the container port to the host, change the host port if necessary | ||
| environment: | ||
| DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm" | ||
| STORE_MODEL_IN_DB: "True" # allows adding models to proxy via UI | ||
| env_file: | ||
| - .env # Load local .env file | ||
| depends_on: | ||
| - db # Indicates that this service depends on the 'db' service, ensuring 'db' starts first | ||
| healthcheck: # Defines the health check configuration for the container | ||
| test: [ "CMD-SHELL", "wget --no-verbose --tries=1 http://localhost:4000/health/liveliness || exit 1" ] # Command to execute for health check | ||
| interval: 30s # Perform health check every 30 seconds | ||
| timeout: 10s # Health check command times out after 10 seconds | ||
| retries: 3 # Retry up to 3 times if health check fails | ||
| start_period: 40s # Wait 40 seconds after container start before beginning health checks | ||
|
|
||
| db: | ||
| image: postgres:16 | ||
| restart: always | ||
| container_name: litellm_db | ||
| environment: | ||
| POSTGRES_DB: litellm | ||
| POSTGRES_USER: llmproxy | ||
| POSTGRES_PASSWORD: dbpassword9090 | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data # Persists Postgres data across container restarts | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -d litellm -U llmproxy"] | ||
| interval: 1s | ||
| timeout: 5s | ||
| retries: 10 | ||
|
|
||
| prometheus: | ||
| image: prom/prometheus | ||
| volumes: | ||
| - prometheus_data:/prometheus | ||
| - ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
| ports: | ||
| - "9090:9090" | ||
| command: | ||
| - "--config.file=/etc/prometheus/prometheus.yml" | ||
| - "--storage.tsdb.path=/prometheus" | ||
| - "--storage.tsdb.retention.time=15d" | ||
| restart: always | ||
|
|
||
| volumes: | ||
| prometheus_data: | ||
| driver: local | ||
| postgres_data: | ||
| name: litellm_postgres_data # Named volume for Postgres data persistence |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,65 @@ | ||
| # LiteLLM Docker | ||
| # Docker Development Guide | ||
|
|
||
| This is a minimal Docker Compose setup for self-hosting LiteLLM. | ||
| This guide provides instructions for building and running the LiteLLM application using Docker and Docker Compose. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Docker | ||
| - Docker Compose | ||
|
|
||
| ## Building and Running the Application | ||
|
|
||
| To build and run the application, you will use the `docker-compose.yml` file located in the root of the project. This file is configured to use the `Dockerfile.non_root` for a secure, non-root container environment. | ||
|
|
||
| ### 1. Set the Master Key | ||
|
|
||
| The application requires a `MASTER_KEY` for signing and validating tokens. You must set this key as an environment variable before running the application. | ||
|
|
||
| Create a `.env` file in the root of the project and add the following line: | ||
|
|
||
| ``` | ||
| MASTER_KEY=your-secret-key | ||
| ``` | ||
|
|
||
| Replace `your-secret-key` with a strong, randomly generated secret. | ||
|
|
||
| ### 2. Build and Run the Containers | ||
|
|
||
| Once you have set the `MASTER_KEY`, you can build and run the containers using the following command: | ||
|
|
||
| ```bash | ||
| docker-compose up -d --build | ||
| ``` | ||
|
|
||
| This command will: | ||
|
|
||
| - Build the Docker image using `Dockerfile.non_root`. | ||
| - Start the `litellm`, `litellm_db`, and `prometheus` services in detached mode (`-d`). | ||
| - The `--build` flag ensures that the image is rebuilt if there are any changes to the Dockerfile or the application code. | ||
|
|
||
| ### 3. Verifying the Application is Running | ||
|
|
||
| You can check the status of the running containers with the following command: | ||
|
|
||
| ```bash | ||
| docker-compose ps | ||
| ``` | ||
|
|
||
| To view the logs of the `litellm` container, run: | ||
|
|
||
| ```bash | ||
| docker-compose logs -f litellm | ||
| ``` | ||
|
|
||
| ### 4. Stopping the Application | ||
|
|
||
| To stop the running containers, use the following command: | ||
|
|
||
| ```bash | ||
| docker-compose down | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - **`build_admin_ui.sh: not found`**: This error can occur if the Docker build context is not set correctly. Ensure that you are running the `docker-compose` command from the root of the project. | ||
| - **`Master key is not initialized`**: This error means the `MASTER_key` environment variable is not set. Make sure you have created a `.env` file in the project root with the `MASTER_KEY` defined. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain why this missing was causing the prisma issue? @mdiloreto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @krrishdholakia, apparently Prisma ORM requires OpenSSL to function correctly, particularly for its Query Engine. When using Prisma with Alpine Linux, which uses musl libc instead of glibc, specific considerations for OpenSSL are necessary. https://www.prisma.io/docs/orm/reference/system-requirements
Not sure why i didn't detected this in the Dockerfile.non_root 🤔 so that's why i created a readme for a formal process to tests this changes using docker-compose.yaml with dummy database, master-key and so on.