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
Local Docker Deployment & Instructions #1193
base: main
Are you sure you want to change the base?
Conversation
Having SUPABASE_SERVICE_ROLE_KEY or any other secrets in the repo code is never a good thing. |
@emsi Thank you for the comment. I understand your concern. I am using the standard example provided by Supabase's repo Supabase env.example This simplifies the basic setup. The user/developer can adjust their security settings as they see fit once deployed. Otherwise we would use a customized .env file. Thank you for the feedback. |
@davidamacey
|
@Bortus-AI The error you see is from the types.ts file within the supabase folder. The types.ts file is autogenerate from the gen-datatypes command. I suggest you re-run FYI I am working on updates to the docker compose to be more efficient in connecting to the Supabase containers. Thank you for trying out my PR. Let me know if you have more questions. |
Happy to help and look forward to the next version. Here is what happened with those commands
|
I attempted to reorganize the docker-compose to leverage the Supabase containers and docker network. Unfortunately, the front-end container struggles to connect. I must use the 'network_mode: host' for the UI container. This is not advised, but otherwise it is not able to see the supabase_kong_chatbotui container. Additionally the front-end throughs exceptions and errors stating it cannot reach the container. The Supabase setup is automated through the cli, so it is difficult to incorporate into one docker-compose/network. Unfortunately, I have hit my knowledge limit of Docker for this particular task. This pull request allows you to build a fully Docker application accessible on local machine and accessible on other machines on the network via port forward. Best Regards, David |
Sorry I looked over your response. I have this similar issue once before. Try renaming the types.ts file to something else. Be sure you are in the repo directory, supabase running, then run the gem-types command. This should generate a new types.ts file. Note, I had troubles similar as I pulled before a large commit was done, but I thought I fixed the types file issue. |
Did you base your attempt on this compose file https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml ?
That also stopped my first attempt. But without its not really a dockerized solution. |
@jmtatsch Thank you for taking a look, maybe with a second set of eyes we can figured it out. In my attempt I still utilize the Supabase CLI to start the backend, but leverage the docker network to connect to the Supabase containers. Docker Attempt NotesI use the docker-compose from this PR to build the UI and ollama containers. I commented out the with 'ATTEMPT DOCKER COMOSE' sections I edit the .env file to use the container names in the URL, see below for .env issues. If the chatbot-ui is not in 'network_mode: 'host'' then the app will not render in the UI. There seems to be a weird connection issue with the frontend and the kong container. Because within the chatbot-ui container I can curl to Ollama and kong containers. I suspect there are some variables or settings in the chatbot-ui frontend that references specific connection types, but I am not a UI dev, so I do not know how to troubleshoot. Verified with the network setup that all containers are on the same network, therefore they should all be referenced by their container names instead of localhost to 127... From supabaseYes I attempted to create the docker-compose from the Supabase repo. I used the .toml from the chatbot-ui and created a docker-compose file. This creates an issue of starting the Supabase containers and initializing with the chatbotbui migration scripts. I could not find documentation to start a docker setup from scratch. From the docs, you would need to have a local supabase running, then migrate that to a 'cloud' version (or running docker setup). This attempt was unsuccessful. Weird ENV IssueIn an attempt to centralize the .env file and read into the UI container via docker env, it will not run properly unless the .env file is built into the UI container. I am not sure where/how the front end is referencing the specific file. So it must be rebuilt if there is an .env change. ChangesPushed these updates to my fork.
I have attempt many permutations of these changes above and the only way for the frontend to connect to the supabase is through network_mode = host. I even tried an NGINX proxy in front of the localhost version. That presents it own issues from the frontend, as it references localhost urls and there is a header mismatch; see env issue above. ScreenshotAttached is a UI screenshot from browser when using the docker-compose setup using none network_mode host and URLs of container names. The frontend cannot connect to the kong containers. I hope this explanation was useful or helpful, but I don't see a way forward at the moment. |
I was able to fix it. I had to update nodejs and then all worked |
@davidamacey |
in the make file there is a command This assumes supabase and ollama are already running. You can use an any of the commands in the Makefile in any order to customize your needs; or make new ones. :) Glad you were able to get your issue fixed! |
@davidamacey Thanks for that command. Whether I use it or make start-chatbot-docker the container chatbot-ui-chatbot-build-ui-1 starts but then exits with an error code. Logs below
|
I am wondering if it's possible to fully encapsulate both Supabase and the app within a single container. This approach would aim to somewhat replicate the simplicity of V1 deployment. In its current form, V2 requires users to dedicate a significant amount of time to understanding how Supabase functions and to implementing it properly within their local environments. It might be worth exploring the s6 overlay for this purpose. |
Totally agree |
I've also built this to run in a docker container, and hit some of the same issues. Anyway I hope this may help anyone else going down the same path. I'm not a next.js expert btw, so what I'm suggesting may not be the true next.js way! Here's my Dockerfile for a start... https://github.com/jollytoad/chatbot-ui/blob/org/Dockerfile I also had the problem with env vars, which it seems that next.js wants to compile inline, which I really don't like the idea of one bit. So I inject the vars at runtime into the html doc, and read them from there...
This allows the built container to be independent of the supabase instance at least. Also, I had a problem with the fact that requests appear to come from I'd be interested if anyone knows a better way to deal with these issues. |
Linking this as it's related:
|
There's been a massive influx of enterprise demand, so lots going on to try and get feedback from teams on how to best go about this. Trying to strike a balance between simplicity and power. |
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.
I guess the .env.local file should not be committed to the repo
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.
or a .env.local.example
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.
the .env.local
As far as I understood, this file should be a .gitignored file which contains the API_KEYS and the like for the local environment without always having it popping up in the git changes.
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.
Wouldn't it make sense to add all those commands simply to the package.json
so that npm
is the only tool (instead of introducing make
)?
@@ -0,0 +1,38 @@ | |||
# Use the Node.js official image as a parent image | |||
# FROM node:20 | |||
FROM node:21.5.0-bookworm |
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.
Should this be node:20-bookworm?
Node 20 is the current LTS version
Hi everyone, after a couple weeks of on and off work, I've managed to shrink this whole thing to just one docker-compose with 8 extra files. The only catch is that it requires some kind of DNS. I made it a separate project here as I think it's currently too unwieldy to merge, and I imagine too different from what will eventually appear here officially. Please try it out if it serves your needs and if you can, deliver feedback, I would appreciate it. |
Thanks @kpi88 you did great! I'm going to be able to try chatbot-ui V2 finally 🙏 |
Anyone tried this, i got this error |
Hello Guys I tried to deploy the chatbot UI on Server
Download this repository cd chatbot-ui update config.toml with your server IP address at three places and update migrations file with same server Ip cd .. (in supabase Directory ) Run this command it will start all the containers that are required Come back to chatbot UI Create a Dockerfile FROM node:21.5.0-bookworm WORKDIR /usr/src/app COPY package*.json ./ RUN npm cache clean -f COPY . . RUN npm run build ENV NODE_ENV production EXPOSE 3000 CMD ["npm", "start"]
Its wokring with Ip |
Hi, just as info, I tried @kpi88 solution. You mention under https://github.com/kpi88/chatbot-docker#known-issues issues with podman. Actually I get the same issues with docker: The unhealthy containers; the ulimits-attribute but also the name-attribute at the beginning and the tags attribute. When removing the unknown attributes, I get the unhealthy containers. Thus, it might not be specifically linked to podman. |
Okay |
@Aj7Ay with your solution, I follow it literally an then get:
|
Docker Deployment
In order to serve this application on my system I prefer Docker Instances for ease of deployment. In an order to setup easily, I created a Makefile, Scripts, and commands to run from the console to increase deployment flexibility.
This includes a docker build file for the chatbot-ui, as well as a docker-compose file for deployment of the UI and ollama.
I did my best to model your setup from the legacy branch.
Makefile
Using a Makefile, we can easily run commands to deploy, stop, and remove all or parts of the deployment.
Scripts
New scripts folder includes automatic ollama install and Supabase cli for ease of use. These may need to be updated in the future for versions and their repo updates. In the meantime, they will do the job.
Readme Updated
Updated instructions for using the Makefile with notes necessary for deployment.
Issue #1088 Bug
In order to get the correct output I added the
streaming: false
parameter per Issue post. The output is correct, we just don't see the streaming output.Notes
I did my best to streamline the local deployment. I am open to suggestions and corrections if someone sees a better process or method.
I tested the docker deployment on Ubuntu 22.04 with GPUs.
Thank you!
Your hardworking on this repo is amazing and very much appreciated!