Forem Creators and Builders

9comindia
9comindia

Posted on

bin/rails s -e production -p 3000 -b 0.0.0.0

The command "bin/rails s -p 3000 -b 0.0.0.0" is working fine but in the development environment even with the custom domain name.

While trying to run the rails in production with the command "bin/rails s -e production -p 3000 -b 0.0.0.0", everything fails even though the env variables are set to production in the .env file.

Errors like:

"WARNING: table: "settings_communities" does not exist or not database connection, Settings::Community.community_name fallback to returns the default value.
WARNING: table: "settings_rate_limits" does not exist or not database connection, Settings::RateLimit.user_considered_new_days fallback to returns the default value.
Exiting

/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `exec': PG::UndefinedTable: ERROR: relation "tags" does not exist (ActiveRecord::StatementInvalid)
LINE 8: WHERE a.attrelid = '"tags"'::regclass
^
[Note: the settings_communities and other table names displayed in the error messages are there available in the database; and the db connectivity is good if I just run the command "bin/rails s -p 3000 -b 0.0.0.0".

Any guidance how to run the local installation to production?
thanks.

Discussion (11)

Collapse
akhil profile image
Akhil Naidu

Hey!

What you are trying to acheive is a to create a production instance based upon development instance. I would suggest you not doing that

Problems you might face

  1. You are forced to port forward or use some proxy servers
  2. You will not have a stable database
  3. Your database is not production ready
  4. You need to modify all the necessary ENV variables
  5. When accesssing a reduntant URL, you will not have a 404 Error Image, rather you will have a big fat error
  6. Migrating database is must
  7. Development postgresdb cannot be used as production db, which throws a lot of erros
  8. When you configure your domain, you will see unfamilair docker routing errors because of the intereference of your own created proxy

And there are many more and out of which => few of the problems are the problems you are facing right now, "which is evident from your last couple of posts"

Solution to resolve

Forem has a detailed guide on selfhosting and the team quickly respond to your help tags; if you are following according to the documentation and the required backend eco-system.

If you want to install Forem on your own, using Heroku or Dokku, you need to have prior knowledge of these technolgies and understand the nuances of the Forem.

To summerise

  1. Don't use Forem development instance and try to make it as your Production instance.
  2. Learn more about the Forem eco system, it is starting to build up => so theire is slight learning curve => There are many interesting articles, go through them. Here are few of my articles, following them in order will provide you with the necessary knowledge to selfhost Forem.
  3. If you wanna selfhost, go with the official documentation as your first choice => if for some reason you don't prefer the provided eco-system => then choose to move to other alternative ways of selfhosting => but you might come across issues, "which the Forem team is not aware of."
Collapse
9comindia profile image
9comindia Author • Edited

Thanks for the advice, but I already went down this road.

If someone has a good explanation why the env variables set to production don't work on a VM environment, it would be great.

Is just setting the development environment to production environment and making it work such a hard thing for the community of developers? Hard to believe!!

Collapse
akhil profile image
Akhil Naidu

See, development instance is meant for testing, adding, removing or updating new features. It is to make the life of developers easy; it is not meant for production.

Think of development instance as a living but barely surviving application. Once the feature is working without any issues, we will then push it to production.

Thread Thread
9comindia profile image
9comindia Author • Edited

Exactly, I agree with you; my question is how do we push it to production?

I would like to know if there is a way to push to production other than Dockers and Ansible way.

Looking for a regular developer to answer, no offence meant.

Thanks.

Thread Thread
akhil profile image
Akhil Naidu

For using your custom repo

In my knowledge, there are two ways to push your own modified code to production.

  1. By making docker file and editing the respective containers in the ansible and butane configurations(if it is based on CoreOS)
  2. Building a single container, based on your repository(after editing your repo). Here, you need to use PAAS like Heroku.

Alternative to Heroku

In the option 2, if you prefer hosting on your own dedicated server => the alternative to Heroku is dokku. Dokku is extremely similar to Heroku, but based on selfhost.

Leewardslope is a Forem instance that is based on Dokku and by Personal Repository

GitHub logo leewardslope / leewardslope

A community for constructive discussions; inspired by Forem.


Forem 🌱

For Empowering Community

ruby version rails version Travis Status for forem/forem Code Climate maintainability Code Climate technical debt CodeTriage badge Dependabot Badge GitPod badge Netlify badge GitHub code size in bytes GitHub commit activity GitHub issues ready for dev Honeybadger badge Knapsack Pro Parallel CI builds for dev.to

Welcome to the Forem codebase, the platform that powers dev.to. We are so excited to have you. With your help, we can build out Forem’s usability, scalability, and stability to better serve our communities.

What is Forem?

Forem is open source software for building communities. Communities for your peers, customers, fanbases, families, friends, and any other time and space where people need to come together to be part of a collective See our announcement post for a high-level overview of what Forem is.

dev.to (or just DEV) is hosted by Forem. It is a community of software developers who write articles, take part in discussions, and build their professional profiles. We value supportive and constructive dialogue in the pursuit of great code and career growth for all members. The ecosystem spans from beginner to advanced developers, and all are welcome to find their place…

t2d, Under Construction!

I'm also, working a project related to this; where the users points

  1. His VPS
  2. His repository
  3. Adds the required ENV varibales
  4. And can install it by a click of a button.

GitHub logo leewardslope / t2d

TUI for Dokku-CLI

What is t2d?

t2d aka Talk to Dokku; is a beautiful Terminal User Interface(TUI) powered by dokku. With t2d you will be able to deploy apps in most popular programming languages, link them to most popular databases and all that with almost zero configuration from your side. Apart from all these amazing features it will also save you money along the way.

Our Vision

We started to work on this because current deployment solutions were expensive or hard to configure. With t2d we plan to provide a solution where deployment experience is smooth, enjoyable and affordable.

What is Dokku?

Dokku is Docker-powered Heroku-like tool that allows you to deploy complex applications by simply pushing it via Git repository. Behind the scenes it runs on herokuish, which essentially is emulating same functionalities that you are using when you deploy your apps on Heroku. As it supports all the Heroku buildpacks, it…

Quick References

Collapse
coffeecraftcode profile image
Christina Gorton

Hey @9comindia !
I see you have a lot of questions and want to try to help you out.
Before I do, can you give me an overall idea of what you are trying to do with Forem? If I am remembering correctly you are not using Forem self-host right?

If we have a little idea of what you are trying to accomplish with Forem I think the team would be able to offer more help.

Collapse
9comindia profile image
9comindia Author • Edited

Hi @coffeecraftcode , if your query was about the purpose of my forem instance, I am trying to create a web platform and an android app for people to have logical discussions on various topics. (Topics are yet to be decided).

I still have many custom requirements like restricting the user roles on creating new topics/tags, approval mechanisms, etc. apart from the credit and badges changes.

But I need to get the web site and android app running before getting into the customization help.

Here is the website. logicrace.com

The blocker issues right now are:

  1. Steps to use the Android app code.
  2. Changing the development environment mode to the production environment mode.

[Note: I didn't use the Dockers as well, it's just a plain local installation on the cloud VM]

Thank you.

Collapse
coffeecraftcode profile image
Christina Gorton

Hey!

Thanks for the added detail. I was asking for the purpose of your instance so I could get a better idea of what you were using the code for and to see if we could help.

I've talked to the team about your questions here and while we fully encourage you to continue asking the community on forem.dev for help if anyone else has used a similar set up, this is outside of our recommended self-host path and as such we cannot provide support.

Our team endeavors to help people out who are following the forem/selfhost instructions and getting stuck. Unfortunately we can't offer much help in this instance since the way you are using Forem is unknown territory for us as well.
Best of luck as you continue to work on this project! If you do decide to use the self-host repo instead of the path you're currently taking let us know and we'll be happy to help if you get stuck :)

If it is ok with you I would love to add all of your questions in to one post that we can tag with #communityhelp to see if anyone else in the community has a similar set up to you and can offer advice. Would you be ok with me doing that and posting it under the Forem team for more visibility? That way if you have any more qusetions you can also just comment on that post instead of having to create another.

Thread Thread
9comindia profile image
9comindia Author

That's great! thank you.

Thread Thread
coffeecraftcode profile image
Christina Gorton

Here is the post with your #help posts in one place. Hopefully some community members can help you get things sorted 🤞

Questions from the Community: Can you help?

Collapse
9comindia profile image
9comindia Author • Edited

yes, I am not using Forem selfhost, I am using the github.com/forem/forem.git code to deploy on a ubuntu cloud VM (other than aws, gcp and digitalocean) in production. [Not using the Dockers, plain local installation on the cloud VM instance]

Till now, I am able to do are:

  1. Able to install forem instance and launch the forem instance in development environment.
  2. Configured nginx as reverse proxy to the custom domain name.
  3. Posts, comments, hearts, saves, etc are working fine.
  4. emails are working fine.

5 Image upload is happening, but the storage is happening on the VM locally.

Major issue pending:

  1. Image upload in not happening on aws S3 or cloudinary, even though the credentials are set in the .env file.

I am suspecting this issue is because my rails server is running in development mode instead of the production mode.

{Note: I have already set Rails, Node and Rack environments to production in the .env file. But the Rails server is taking only the development mode.]

So could you please help me on steps how do I change my development environment to production environment? thank you.