Trying to deploy a rails application in a cloud provider ie dreamhost, that uses OpenStack these are the steps needed:
- Install docker in your development machine and your cloud provider by following the installation instructions from here
- Create an account in Docker Hub, that will be needed later on to push your docker image with the application
- Pull the official rails docker image to your development environment:
sudo docker pull rails:latest
- Create a new simple rails application:
- Change to the application directory and add a Dockerfile in the root directory containing the following:
- Build your new image by using:
sudo docker build -t rails_docker_test .
- Check that your image was build by using:
- Start the container with:
sudo docker run --name rails_test -p 0.0.0.0:3000:3000 -d rails_docker_test
- Make sure that you can see the initial rails page by using your browser to go to http://127.0.0.1:3000
- Push your image to your Docker Hub account by first logging in to it from the command line:
, and then when you get ‘Login Succeeded’, push your image to your account:
sudo docker login --username=yourhubusername --firstname.lastname@example.org
sudo docker push yourhubusername/rails_docker_test
You have just created your first instance in Dreamhost’s new service DreamCompute using OpenStack and you would like to login with ssh, but you get ‘Permission Denied’.
The solution is described here, and it’s the fact that the user name that you need to use is not your Dreamhost account name, or the DreamCompute dashboard user anme but the the username called:
NOTE: It seems that is also described here, at the bottom.
After installing rvm on dreamhost, when trying to install any ruby version afterwards, there is a prompt for password, and when entering the user’s password there is the message that the user is not in the sudoers list.
To be able to install the rvm ruby version you would like you should be installing them by using the following which is based on the answer here :
rvm list remote
rvm mount -r https://rvm.io/binaries/debian/6/x86_64/ruby-2.0.0-p247.tar.bz2 --verify-downloads 1
When trying to use the new Capistrano 3.x to set up your rails project in a dreamhost account, you get the following error complaining that the git-ssh.sh script copied to your account by capistrano cannot be executed as the permission is denied:
fatal: cannot exec '/tmp/example.com/git-ssh.sh': Permission denied
It seems that Dreamhost, and quite possibly other hosting providers are not allowing executables from the /tmp directory, which is where Capistrano places the git-ssh.sh script. So in order to be able to execute the script you can change the directory where the script is copied in the first place and put it in your home directory. You can do that by adding the following to the config/deploy.rb file:
set :tmp_dir, "/home/dh_user_name/tmp"
After the announcements in the previous posts about the security vulnerabilities in Rails 3.0.3, you would like to update your application and deploy with the latest 3.0.4 version.
- Change your Gemfile to replace
gem 'rails', '3.0.3'
gem 'rails', '3.0.4'
bundle update rails
- Remove the old gems by using:
git rm name_of_3.0.3_gem
- Add the new gems to your git
git add vendor/cache
- Check in to your repository the new files
git commit vendor/cache -m 'upgrade to rails 3.0.4'
- Make sure that you also check in both your Gemfile and Gemfile.lock into your git repository
git commit Gemfile Gemfile.lock -m 'update Gemfiles to use 3.0.4'
otherwise when you try to deploy you will see the error:
You have modified your Gemfile in development but did not check the resulting snapshot (Gemfile.lock) into version control
- push everything to your git repository:
- Deploy your application with capistrano as usual:
- Your new gems for 3.0.4 should be installed on the share/bundle folder
You want to deploy your Rails 3.0.3 in Dreamhost with capistrano, but even though you follow the steps from a previous post here, when you go to the application’s main page you still get an error:
500 Internal Server Error
Thanks to a blog post from Brendon Wilson here, the last missing piece from the puzzle in order to have your application running is to add the following line to the top of your deploy.rb file:
and redo your cap deploy.
You want to deploy your Rails (3.0.3) application to Dreamhost using Capistrano, but you get errors like:
bundle command not found
Enter your password to install the bundled RubyGems to your system:
You may be able to see in your deploy.rb file a commented section that says the following:
As Capistrano executes in a non-interactive mode and therefore doesn’t cause
any of your shell profile scripts to be run ….
So in order for capistrano to be able to find your bundle command you should add in your deploy.rb file a line with your paths (ie):
If you have the previous line your bundle command can run, but if you try to do cap:deploy your bundler will probably give you an error as it would ask for your sudo password. In order to avoid this error and to make it work you have to add another line with your gem path (ie):
making sure that your home directory path for your gems is first in the list.
According to a dreamhost post here, you should be upgrading your WordPress installation as soon as possible.
You are hosting your MySQL server in a shared host which is in a different country from your application’s local timezone, and you cannot change the MySQL system timezone, but you would like to use sysdate for date comparisons.
In your SQL query that you use for comparing with the system date/time, use the convert_tz function in MySQL, using the appropriate local time zone (ie Europe/London):
You have set up your capistrano recipe for deployment to dreamhost using password less logins, but after dreamhost moves your git repository server to a different server, the deployment breaks, with ‘permission denied’ when trying to get the git repository.
As the server was moved you would need to copy your ssh public key from the deployment server to the new server again for the password-less logins to work again.
Follow the details here how to copy your public key across, login in once with your password, and after that your capistrano recipe should be working again as normal.