Fix docker compose persistence issue and use multistage builder pattern to shrink chroma docker image (#456)

## Description of changes

Clickhouse data was being saved in an anonymous volume. Anonymous
volumes are not removed by default. However, as they don’t have a stable
name, they will not be automatically mounted by a subsequent `docker
compose up`. For data that needs to persist between updates, use
explicit paths as bind mounts or named volumes.
https://docs.docker.com/engine/reference/commandline/compose_down/#usage

The yaml in the repo makes it look like
clickhouse_data:/bitnami/clickhouse is where the data is supposed to go
but that isn't what's happening.

Modified Dockerfile to use multistage builder pattern to shrink the
docker image. The new image is 800MB smaller than the official chroma
image.

## Test plan

Build image locally. Unit tests all passed. Data persists after bringing
compose stack down and up. No actual chroma code change in this PR.
![chroma new
image](https://user-images.githubusercontent.com/52208818/235955676-bf5bf058-e02c-47e8-8c0b-6638d671280b.png)

## Documentation Changes

None required.

---------

Co-authored-by: perry <perryaws2021@protonmail.com>
Co-authored-by: Jeffrey Huber <jeff@trychroma.com>
This commit is contained in:
perryrobinson
2023-05-15 18:08:25 -05:00
committed by GitHub
parent 95fc59768a
commit d88860bbc5
2 changed files with 16 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ networks:
services:
server:
image: server
build:
context: .
dockerfile: Dockerfile
@@ -34,7 +35,8 @@ services:
- '8123:8123'
- '9000:9000'
volumes:
- clickhouse_data:/bitnami/clickhouse
- clickhouse_data:/var/lib/clickhouse
- clickhouse_logs:/var/log/clickhouse-server
- backups:/backups
- ./config/backup_disk.xml:/etc/clickhouse-server/config.d/backup_disk.xml
- ./config/chroma_users.xml:/etc/clickhouse-server/users.d/chroma.xml
@@ -44,6 +46,8 @@ services:
volumes:
clickhouse_data:
driver: local
clickhouse_logs:
driver: local
index_data:
driver: local
backups: