Closed krschacht closed 1 month ago
@hopeseekr Here is the issue where I'll track this. I switch between running in docker locally and running in plain rails just so I catch stuff. I switched over to docker just now and it's working for me so I haven't been able to repro your issue.
Next I'm going to blow away my local image completely and start fresh. It may have been recent PR must have inadvertently broken this. We just recently expanded the number of hosting options we may have inadvertently broken some situation which I'm not seeing yet.
But it's important to me that we keep things in a stable state and I test it regularly! We even have an automated CI build for docker images which I thought would protect me from inadvertently breaking them but clearly that's missing something.
Investigating...
I just noticed you said "I want to run this via docker in production." But you made reference to editing development.rb.
This issue that you're describing, I am assuming you:
docker compose up --build
Is that correct? I want to make sure we address any local issues first before the production question.
And... I just did a fully fresh install and couldn't repro your issue that way either. I pulled the latest main, opened Docker Desktop and removed all containers/images/volumes/builds, and then ran docker compose up --build
and it completely initialized everything from scratch.
@hopeseeker — I'm not sure what else to try so I'll wait for you to catch up on this thread. I'm not yet sure what's different about your setup than the fresh setup that I just did.
Hi, If it helps I just cloned the repo and trying to launch it locally I got the same error (just with a plain Rails server, no docker).
Here are the steps I followed to fix it :
- bundle config set force_ruby_platform false
- bundle install
- bundle exec rake assets:precompile
@mathieubrunpicard Hmm, this is helpful to hear, but you shouldn't have had to do any of this. I clearly need to fix something. But are you running the app in development mode or are you trying to turn it into production mode, locally? Or here's a clearer question:
Did you clone the repo and followed the setup steps in the README (specifically, this section: https://github.com/allyourbot/hostedgpt#contribute-as-a-developer )? And doing this you got the error above about tailwind not being present?
@mathieubrunpicard Hmm, this is helpful to hear, but you shouldn't have had to do any of this. I clearly need to fix something. But are you running the app in development mode or are you trying to turn it into production mode, locally? Or here's a clearer question:
Did you clone the repo and followed the setup steps in the README (specifically, this section: https://github.com/allyourbot/hostedgpt#contribute-as-a-developer )? And doing this you got the error above about tailwind not being present?
Actually, I followed the steps but I had an error launching the docker compose up command. So what I did was
- bundle install
- rails db:setup
- rails s
And then I had the same error as OP
Ohhhh, @mathieubrunpicard, I get it. Those are the wrong command. :) I totally get why you executed that since it's the old way of running a new rails app, whereas now Procfile's are the default configuration and merely running rails server
does not use the Procfile.
But clearly lots of people are going to execute this out of old habit.
I just pushed a hotfix to main that detects if someone merely ran "rails server" and displays a warning message with instructions to run bin/dev
instead. Hopefully this "fixes" the issue!
$ bin/rails s
=> Booting Puma
=> Rails 7.1.3.2 application starting in development
=> Run `bin/rails server --help` for more startup options
###
### WARNING: You are running 'rails server' outside of the Procfile. This misses the SolidQueue and Tailwind.
###
### Cancel this with Ctrl + c and instead run 'bin/dev'
###
### Full setup instructions are here: https://github.com/allyourbot/hostedgpt#contribute-as-a-developer
### (Or, press Enter to proceed anyway)
###
Now, while we're at it, do you know what the error was when launching docker compose up --build
? It would be nice for me to fix that too. :)
I'm getting the warning (and early exit) when using docker compose up --build
. I'm able to get things running with the following, but there may be a better approach. Note that bin/dev
runs with bash
and not sh
.
diff --git a/Dockerfile b/Dockerfile
index ba37722..6fd6c66 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -91,7 +91,7 @@ EXPOSE 3000
# RUBY_VERSION is the only thing used from anything above
FROM ruby:${RUBY_VERSION}-alpine AS development
-RUN apk add --no-cache git build-base postgresql-dev curl-dev gcompat tzdata vips-dev imagemagick
+RUN apk add --no-cache bash git build-base postgresql-dev curl-dev gcompat tzdata vips-dev imagemagick
ENV BUNDLE_CACHE=/tmp/bundle \
BUNDLE_JOBS=2 \
@@ -106,7 +106,7 @@ RUN --mount=type=cache,id=gems,target=/tmp/bundle \
RUN apk add --no-cache postgresql-client
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
-CMD ["./bin/rails", "server", "-b", "0.0.0.0"]
+CMD ["./bin/dev"]
#### END of DEV ####
Edit - I also had to add -b 0.0.0.0
to the web
entry of Procfile.dev
@matthewbennink I'm sorry for being slow to circle back on this, but I'm looking at this now and there is absolutely an issue — and your fix is working for me. Thank you for taking the time to write this up. I really appreciate it. I feel bad that I had the Docker setup broken for multiple days (maybe weeks?)... :(
In any case, I did a spike on this right now. I incorporated your fixes and I eliminated some of the differences that existed between running the app inside docker and outside of docker. This should reduce the possibility of it getting broken again in the future. And I'll try to be better about running the app myself in both environments. I tend to fall into one and don't switch over often enough to the other.
Thanks again for your help on this
Hi thank you so much for investigating this issue.
I’m wanting to run this on a production system.
It’s the first exposure to Ruby I’ve ever had, so I don’t know what I’m doing.
It works!!
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi --force $(docker images | grep hostedgpt | awk '{print $3}')
git pull
docker compose build
docker compose up
Woohoo!
Glad to hear it. Enjoy!
When you do
docker compose up
now you get hit with:So I went in and edited
config/environments/development.rb
and changed line 79 fromto
so that it, you know, runs on Docker networks...
But then I get hit with a big-ole Sprockets::Rails::Helper::AssetNotFound in Sessions#new
The asset "tailwind.css" is not present in the asset pipeline.
error.![image](https://github.com/allyourbot/hostedgpt/assets/1125541/b7c131ff-c718-42b6-a23c-f524f3d998b9)
Also, I want to run this via docker in production. How do I change the environment???
It seems you left stuff out of the README and/or the docker compose setup has bitrotted in just 3 months to the point of not being able to be setup on the first run.
Originally posted by @hopeseekr in https://github.com/allyourbot/hostedgpt/issues/125#issuecomment-2119051454