-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Docker compose setup gives: No community record matching Host='localhost:3000' #759
Comments
I understand it comes from this part of the application_controller.rb def setup_request_context
RequestContext.clear!
host_name = request.raw_host_with_port # include port to support multiple localhost instances
RequestContext.community = @community = Rails.cache.fetch("#{host_name}/community", expires_in: 1.hour) do
Community.unscoped.find_by(host: host_name)
end
Rails.logger.info " Host #{host_name}, community ##{RequestContext.community_id} " \
"(#{RequestContext.community&.name})"
if RequestContext.community.blank?
render status: :unprocessable_entity, plain: "No community record matching Host='#{host_name}'"
return false
end
true
end I did find a partial solution # Go into the uwsgi container
$ docker exec -it qpixel-uwsgi-1 bash
# And start a rails console
$ rails c
# in the rails console run:
Community.create(name: 'Dev Community', host: 'localhost:3000')
Rails.cache.clear |
So this worked I nearly have it working locally, it was indeed the clearing of the cache. The only thing left is making a post, and that step is not yet working for me.... (step 7 of the docker readme) But I am stuck at this screen when I want to create post. I have created a category Q&A with tag set Main and Meta with a tag set Meta. I tested the VM based approach in the main readme (with vagrant and Ansible ) and became stuck at the same point, I have the site running but cannot create posts. post_types.html.erb h1>What kind of post?</h1>
<p class="has-font-size-larger has-color-tertiary-500">
This category has more than one type of post available. Pick a post type to get started.
</p>
<% @post_types.each do |pt| %>
<h3><%= link_to pt.name.underscore.humanize, new_category_post_path(post_type: pt, category: @category) %></h3>
<p class="has-color-tertiary-500"><%= pt.description %></p>
<hr/>
<% end %> Related: |
@RobertFloor just to make sure. Could you show a screenshot of the category config for that category with all settings expanded? |
Ah I think you'll need to click on the "Edit allowed post types" link and choose which post types you want to allow in that category. (Yes, I know, that's very much not obvious and we should update the instructions accordingly 😬) |
I think I also found the root cause of the failure of the docker compose error. I believe it is in the file https://github.com/codidact/qpixel/blob/develop/docker/create_admin_and_community.rb. This function needs the variable The code in question is # 1. Create the community
community_name = ENV['COMMUNITY_NAME'] || 'Dinosaur Community'
Community.create(name: community_name, host: "localhost:#{ENV['LOCAL_DEV_PORT']}") docker exec -it qpixel-uwsgi-1 bash
root@bd4a122c2f6a:/code# rails c
irb(main):001:0> community_name = ENV['COMMUNITY_NAME'] || 'Dinosaur Community'
=> "Dev Community"
irb(main):002:0> Community.create(name: community_name, host: "localhost:#{ENV['LOCAL_DEV_PORT']}")
(0.3ms) SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
(0.2ms) BEGIN
Community Exists (0.4ms) SELECT 1 AS one FROM `communities` WHERE `communities`.`host` = BINARY 'localhost:' LIMIT 1
(0.2ms) ROLLBACK
=> #<Community id: nil, name: "Dev Community", host: "localhost:", created_at: nil, updated_at: nil, is_fake: false, hidden: false>
irb(main):003:0> ENV['LOCAL_DEV_PORT']
=> nil The variables in the container root@bd4a122c2f6a:/code# env
HOSTNAME=bd4a122c2f6a
COMMUNITY_ADMIN_PASSWORD=password
RUBY_DOWNLOAD_SHA256=5db187882b7ac34016cd48d7032e197f07e4968f406b0690e20193b9b424841f
RUBY_VERSION=2.6.6
PWD=/code
NODEJS_HOME=/opt/node-v12.18.3-linux-x64/bin
MYSQL_ROOT_PASSWORD=qpixel
BUNDLE_APP_CONFIG=/usr/local/bundle
RUBY_MAJOR=2.6
COMMUNITY_ADMIN_USERNAME=admin
MYSQL_PASSWORD=qpixel
MYSQL_USER=qpixel
HOME=/root
LANG=C.UTF-8
CONFIRMABLE_ALLOWED_ACCESS_DAYS=2
BUNDLE_SILENCE_ROOT_WARNING=1
COMMUNITY_NAME=Dev Community
GEM_HOME=/usr/local/bundle
TERM=xterm
SHLVL=1
MYSQL_DATABASE=qpixel
COMMUNITY_ADMIN_EMAIL=admin@noreply.com
PATH=/opt/node-v12.18.3-linux-x64/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RAILS_ENV=development
RUBYOPT=-KU -E utf-8:utf-8
_=/usr/bin/env |
So it can be fixed by the following 2 fixes 2 Add version: "3.8"
services:
db:
build:
context: "."
dockerfile: docker/Dockerfile.db
volumes:
- ./docker/mysql:/var/lib/mysql
env_file:
- ${ENV_FILE_LOCATION}
command: mysqld --default-authentication-plugin=mysql_native_password --skip-mysqlx
uwsgi:
restart: always
build:
context: "."
dockerfile: docker/Dockerfile
depends_on:
- db
environment:
- COMMUNITY_NAME=${COMMUNITY_NAME}
- RAILS_ENV=${RAILS_ENV}
- CONFIRMABLE_ALLOWED_ACCESS_DAYS=${CONFIRMABLE_ALLOWED_ACCESS_DAYS}
- LOCAL_DEV_PORT=${LOCAL_DEV_PORT}
env_file:
- ${ENV_FILE_LOCATION}
ports:
- "${LOCAL_DEV_PORT}:3000"
volumes:
- .:/code
- ./static:/var/www/static
- ./images:/var/www/images
links:
- redis
- db
redis:
restart: always
image: redis:latest
depends_on:
- db |
Created a pull request to fix this issue |
@RobertFloor when you click on "Edit Category", which post types are selected under "Posting" > "Listed post types"? (for expected results, there should probably be Question and Article selected) |
Thanks that made a change :) This posts are visible now So the only problem is I only have these categories, no questions
|
Definitely related to #638 and https://collab.codidact.org/posts/285521 I saw the same behavior. The question post type does not seem to be seeded correctly in the database and the seed script silently continues. |
Describe the bug
First congratulations on this nice project. I wanted to run it locally so I followed using docker-compose procedure in the docker/README.md file to get qpixel running locally. However, I end up with this in the browser:
No community record matching Host='localhost:3000'.
Probably I am missing a setting but I cannot find the correct place to fix the communities in the docker or variables file.To Reproduce
Steps to reproduce the behavior:
1 Start with the develop branch and run these commands
Expected behavior
I expect the webserver to start and show the webpage as described after step 4 in the readme.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Logs
I do see this error for the database container:
Related issues
I did find this issue with the same problem at the end of the issue but have not found a solution in it: #70
The text was updated successfully, but these errors were encountered: