Skip to content

Commit

Permalink
Dockerized chroma arguments customization (#1658)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - New functionality
- Added an ability to customize the default arguments that are passed
from `docker run` or `docker compose` `command` field to `uvicorn
chromadb.app:app`. I needed it to be able to customize the port because
in certain scenarios it cannot be change (i.e. ECS where internal port
is proxies as is). The default arguments are not changed: `--workers 1
--host 0.0.0.0 --port 8000 --proxy-headers --log-config
chromadb/log_config.yml --timeout-keep-alive 30`
	 - Added ENV variables for basic customization with default values:
```	 
CHROMA_HOST_ADDR="0.0.0.0"
CHROMA_HOST_PORT=8000
CHROMA_WORKERS=1
CHROMA_LOG_CONFIG="chromadb/log_config.yml"
CHROMA_TIMEOUT_KEEP_ALIVE=30
```

## Test plan
*How are these changes tested?*

- Tested locally using `docker build` and `docker run` commands
- Tested customization in `docker-compose` - now it works as expected.

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*

TODO: Deployment docs needs to be updated to cover container arguments
customization.
  • Loading branch information
MrZoidberg committed Feb 7, 2024
1 parent a62cfb0 commit 691ac3f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ COPY --from=builder /install /usr/local
COPY ./bin/docker_entrypoint.sh /docker_entrypoint.sh
COPY ./ /chroma

RUN chmod +x /docker_entrypoint.sh

ENV CHROMA_HOST_ADDR "0.0.0.0"
ENV CHROMA_HOST_PORT 8000
ENV CHROMA_WORKERS 1
ENV CHROMA_LOG_CONFIG "chromadb/log_config.yml"
ENV CHROMA_TIMEOUT_KEEP_ALIVE 30

EXPOSE 8000

CMD ["/docker_entrypoint.sh"]
ENTRYPOINT ["/docker_entrypoint.sh"]
CMD [ "--workers ${CHROMA_WORKERS} --host ${CHROMA_HOST_ADDR} --port ${CHROMA_HOST_PORT} --proxy-headers --log-config ${CHROMA_LOG_CONFIG} --timeout-keep-alive ${CHROMA_TIMEOUT_KEEP_ALIVE}"]
12 changes: 11 additions & 1 deletion bin/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash
set -e

export IS_PERSISTENT=1
export CHROMA_SERVER_NOFILE=65535
exec uvicorn chromadb.app:app --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
args="$@"

if [[ $args =~ ^uvicorn.* ]]; then
echo "Starting server with args: $(eval echo "$args")"
echo -e "\033[31mWARNING: Please remove 'uvicorn chromadb.app:app' from your command line arguments. This is now handled by the entrypoint script."
exec $(eval echo "$args")
else
echo "Starting 'uvicorn chromadb.app:app' with args: $(eval echo "$args")"
exec uvicorn chromadb.app:app $(eval echo "$args")
fi
2 changes: 1 addition & 1 deletion docker-compose.test-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
dockerfile: Dockerfile
volumes:
- chroma-data:/chroma/chroma
command: uvicorn chromadb.app:app --workers 1 --host 0.0.0.0 --port 8000 --log-config chromadb/log_config.yml --timeout-keep-alive 30
command: "--workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30"
environment:
- ANONYMIZED_TELEMETRY=False
- ALLOW_RESET=True
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
dockerfile: Dockerfile
volumes:
- chroma-data:/chroma/chroma
command: uvicorn chromadb.app:app --workers 1 --host 0.0.0.0 --port 8000 --log-config chromadb/log_config.yml --timeout-keep-alive 30
command: "--workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30"
environment:
- ANONYMIZED_TELEMETRY=False
- ALLOW_RESET=True
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
# Default configuration for persist_directory in chromadb/config.py
# Read more about deployments: https://docs.trychroma.com/deployment
- chroma-data:/chroma/chroma
command: uvicorn chromadb.app:app --reload --workers 1 --host 0.0.0.0 --port 8000 --log-config chromadb/log_config.yml --timeout-keep-alive 30
command: "--workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30"
environment:
- IS_PERSISTENT=TRUE
- CHROMA_SERVER_AUTH_PROVIDER=${CHROMA_SERVER_AUTH_PROVIDER}
Expand Down

0 comments on commit 691ac3f

Please sign in to comment.