Having trouble deploying rails application [bundler: failed to load command: rake ] cloudfoundry - cloud-foundry

I am trying to deploy a rails 6 application using rails buildpack on ibmcloud cloudfoundry but in vain. I get a rake error bundler: failed to load command: rake
https://i.stack.imgur.com/owDQO.png

So after digging around and getting to understand my logs better, I had to update bundle globally for some reason and in due process updated rake. Then I had to create a rake task and put it in the lib folder under task. This automatically gets called in the Rakefile.
After that, in my manifest file, i had inlcuded the command: bundle exec rake cf:on_first_instance db:migrate && bundle exec rails s -p $PORT -e $RAILS_ENV, which now was able to be called while deploying the rails 6 app on cf and run the rake tasks there after.

Related

Getting "Could not locate Gemfile" installing a Redmine plugin in docker

Trying to install a plugin in redmine, using docker. I'm new to redmine, and just know the docker basics. I have no knowledge of Ruby, so idk how those Gemfiles installations work.
I'm trying to install Issue recurring. The installation instructions for the plugin look straightforward:
su - redmine
git -C /var/lib/redmine/plugins/ clone https://github.com/cryptogopher/issue_recurring.git
cd /var/lib/redmine
bundle install
RAILS_ENV=production rake redmine:plugins:migrate
So I tried to translate that into a Dockerfile:
FROM redmine:3.3
RUN mkdir -p /var/lib/redmine/plugins/
RUN chown -R redmine:redmine /var/lib/redmine
#su - redmine
USER redmine
RUN git -C /var/lib/redmine/plugins/ clone https://github.com/cryptogopher/issue_recurring.git
#cd /var/lib/redmine
WORKDIR /var/lib/redmine/
#bundle install
RUN bundle install
#RAILS_ENV=production rake redmine:plugins:migrate
ENV RAILS_ENV production
RUN rake redmine:plugins:migrate
But what I get is:
...
Step 7/9 : RUN bundle install
---> Running in 1139cd4ccb43
Could not locate Gemfile
The command '/bin/sh -c bundle install' returned a non-zero code: 10
Am I doing something wrong here, or is there a bug in the plugin? Being inexperienced in Ruby, I cannot tell. I tried running "bundle install" in "/var/lib/redmine/plugins/" and "/var/lib/redmine/plugins/issue-recurring/" too, but same result.
For anyone looking for solution, it's here: https://it.michalczyk.pro/issues/15
Excerpt:
I found the problem. It's not installed under /var/lib/redmine/, it's installed under "/usr/src/redmine"! I was assuming /var/lib/redmine/ is the standard directory...
The installation instruction of the plugin seems to for non-docker scenario. Try "redmine bundle install" like they have done Here:
https://github.com/docker-library/redmine/blob/master/3.3/Dockerfile#L129

Redmine agile plugin installation failure - No such file to load -- agile_data

I have Redmine 2 on Ubuntu and want to install additional agile plugin. I have added redmine_agile folder downloaded from http://www.redminecrm.com/projects/agile/pages/1 to /usr/share/redmine/lib/plugins and used commands:
sudo bundle install --without development test
sudo bundle exec rake redmine:plugins NAME=redmine_agile RAILS_ENV=production
After last one, I get:
(in /usr/share/redmine)
rake aborted!
No such file to load -- agile_data
Tasks: TOP => redmine:plugins:migrate => environment
How to solve this problem?
I've unpacked plugin into incorrect folder. It should be unpacked into /usr/share/redmine/plugins. Migration command should be run from /usr/share/redmine/

Heroku: run npm install and gulp build for a Django app

I have a Django app that I managed to deploy with Heroku. My Procfile file only contains :
web: gunicorn omegapp3.wsgi --log-file -
So when I run heroku local it works.
But when I deploy with heroku push master, the console detects a Node app because the app has a package.json and then the build fails.
What I would like to do is the following :
run npm install to install gulp etc.
run gulp build.
Do you know how I can do that ?
According to the official documentation, you should add multiple buildpacks to your setup, rather than a single multi buildpack.
For example, if you wanted to deploy an app that uses a Nodejs package (i.e. grunt, gulp, etc) to do some setup on your app, you would run this from your command line:
heroku buildpacks:add --index 1 heroku/nodejs
The add command adds the Nodejs buildpack as an additional buildpack, rather than replacing your current buildpack. Note the --index 1. This specifies that the Nodejs buildpack is the first in the order of buildpacks. This is important because the final buildpack is the one used for actual process type. You can call heroku buildpacks from the command line to verify the buildpack setup. I run a Python app, so my heroku buildpacks looks like this:
=== your_app_name_here Buildpack URLs
1. heroku/nodejs
2. https://github.com/heroku/heroku-buildpack-python
Then, as stated by rocketer, you can place this in your package.json file to be run on deploy:
"scripts": {
"postinstall": "./node_modules/.bin/gulp build"
}
Solved by using $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git.
It allows to use node and python (you have to specify in a .buildpacks file).
In ordre to run gulp build, I added the following to my package.json :
"scripts": {
"postinstall": "./node_modules/.bin/gulp build"
}

RAILS_ENV=production doesn't work

I put "RAILS_ENV=production" rake about doesn't shows up production info.
deployer#proj:/var/www/proj# RAILS_ENV=production rake about
About your application's environment
Rails version 4.2.0
Ruby version 2.2.1-p85 (x86_64-linux)
RubyGems version 2.4.6
Rack version 1.6.1
JavaScript Runtime Node.js (V8)
Middleware Rack::Sendfile, Rack::Loc.......
Application root /var/www/proj
Environment development
Database adapter mysql2
Database schema version 20150615041442
I even try:
export RAILS_ENV=production
RAILS_ENV=production bundle exec rake db:create
bundle exec rake db:create RAILS_ENV=production
have checked in rails console
like this....
Loading development environment (Rails 4.2.1)
try this
ENV['RAILS_ENV'] ||= 'production' in environment.rb
sudo bundle exec rake db:migrate RAILS_ENV=production
sudo bundle exec rake assets:precompile RAILS_ENV=production
this may help you robmclarty.com
stackoverflow.com/a/27434582/3248148
You could set the environment using bin/rails db:environment:set RAILS_ENV=production and then run your rake tasks.

Heroku installing outdated requirements file

Im attempting to deploy a Django app using Heroku.
When I first ran
$ git push heroku master
My original requirements.txt had outdated dependencies and Django failed to deploy. After I edited my dependencies and attempted to deploy I noticed that Heroku is still attempting to install dependencies that I erased. Am I doing something wrong here?