Skip to content
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

Add chat-ui and chat-ui-db docker images #613

Merged
merged 14 commits into from
Dec 8, 2023
Merged

Conversation

nsarrazin
Copy link
Collaborator

@nsarrazin nsarrazin commented Dec 6, 2023

The goal is to end up with a docker image that we can build in CI, that will not contain any secrets. Then users will be able to just docker run chat-ui:latest and mount their .env.local either as a bind volume or as an env variable.

To-do

  • Add an image with mongo included
  • Add a github action for building & publishing the docker image
    Update the readme with steps to run chat-ui using docker only (I will do this in a later PR once i'm sure everything works)

Testing locally

Building the image

(this step won't be needed in the future, as we will build the image in our CI pipeline)

Building the image without db ( chat-ui):

docker build -t chat-ui  -f ./Dockerfile.local .

Building the image with db (chat-ui-db):

docker build -t chat-ui-db --build-arg="INCLUDE_DB=true" -f ./Dockerfile.local .

The chat-ui-db image will override any MONGODB_URL set and will use the included DB instead.

Running the image

Simplest possible run, DB included & default config:

docker run -p 3000:3000 chat-ui-db

Custom config

You can specify a DOTENV_LOCAL by passing an env variable at docker run time:

DOTENV_LOCAL=$(<.env.local)  docker run --rm -e DOTENV_LOCAL -p 3000:3000 chat-ui

Or you can use a bind volume pointing to .env.local directly

docker run --rm --mount type=bind,source="$(pwd)/.env.local",target=/app/.env.local -p 3000:3000 chat-ui

@nsarrazin nsarrazin added enhancement New feature or request CI/CD labels Dec 6, 2023
@gary149
Copy link
Collaborator

gary149 commented Dec 6, 2023

⚠️ this PR moves the config stuff to a subfolder config so you might need to move all your .env* to config/.env*

I think we can revert this and keep it as today.

@gary149
Copy link
Collaborator

gary149 commented Dec 6, 2023

Question, isn't it better to have a single container for each process (and use with Docker compose)?

@nsarrazin
Copy link
Collaborator Author

nsarrazin commented Dec 6, 2023

Question, isn't it better to have a single container for each process (and use with Docker compose)?

That's why if USE_LOCAL_DB is not set to true when running, it uses the db address specified in the .env.local and doesn't start a mongo instance

That way you can use another container if you want or a remote DB

I replaced this setup with two images, one chat-ui and one chat-ui-db see comments below

@nsarrazin
Copy link
Collaborator Author

⚠️ this PR moves the config stuff to a subfolder config so you might need to move all your .env* to config/.env*

I think we can revert this and keep it as today.

8751c6b changes it back!

@nsarrazin
Copy link
Collaborator Author

I've updated the dockerfile and associated workflow in 6a85c2d so that we now build two separate images.

chat-ui without a db (672MB) and chat-ui-db with mongoDB built-in (1310MB), that way if you want to deploy chat-ui without a db you can use a smaller image.

@nsarrazin nsarrazin changed the title Add a Dockerfile.local image to build Add chat-ui and chat-ui-db docker images Dec 7, 2023
@nsarrazin
Copy link
Collaborator Author

cc @XciD I think we talked at some point about making an image that wouldn't need the .env.local for building. This PR moves the npm build step to the entrypoint script so the .env.local is now provided at run time.

@nsarrazin
Copy link
Collaborator Author

Merging this now, it doesn't change anything in code or docs, it just adds extra stuff. I want to see if it builds and deploys correctly to ghcr.

Once it works I'll update the docs.

@nsarrazin nsarrazin merged commit 73b316c into main Dec 8, 2023
@nsarrazin nsarrazin deleted the feat/add_local_docker_image branch December 8, 2023 12:17
ice91 pushed a commit to ice91/chat-ui that referenced this pull request Oct 30, 2024
* Add a `Dockerfile.local` image to build

* Add a build & publish workflow

* fix workflow

* Add support for local mongoDB

* Fix problem with POST requests

* use slim image

* Set mistral to be the default model in .env

* Fix entrypoint

* Revert change regarding config folder

* replace env variable by build arg for DB and update work

* old mention of `conf` folder in readme

* env to .env

* Revert readme changes

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants