Finding the application path after deployment - ruby-on-rails

I successfully deployed my Rails application fireworks_app with Dokku in a Ubuntu 18.04 LTS machine, and now I would like to add a logrotate file for my Rails logs. What is the path of my application and thus of my log files? There is a /home/dokku/fireworks_app folder but this folder contains only the following items:
$ ls
CONTAINER.web.1 DOCKER_OPTIONS_RUN HEAD URLS cache hooks maintenance objects
DOCKER_OPTIONS_BUILD DOKKU_SCALE IP.web.1 VHOST config info nginx.conf refs
DOCKER_OPTIONS_DEPLOY ENV PORT.web.1 branches description letsencrypt nginx.conf.d
I suppose somewhere in the system there is a folder containing my application with the known Rails file structure, but I cannot find it.

Inside your rails application you can do something like Rails.root to get the path to the root directory of your project.
For instance, if the log files are in fireworks_app/lib/log/ you could do Rails.root.join('lib','log','log_file.log') to get the path to that file.

Related

rails by default set tmp/ file permission

I have rails application in docker. Also using gitlab ci for deploy to server. And rails store all cache in tmp folder. When ci starts deploying, they should be delete all cache in tmp file. But in this moment, for tmp file sets sudo permissions and gitlab-runner can't delete cache. By default, tmp file created when application is already started.
Can I indicate in rails configs permission for tmp file, before starting my application.
Or you can advise how to solve my problem.
Look at your config.cache_store in your production.rb file and see where it's set to.
I'd suspect you're running into this: https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-filestore

Opsworks - Rails application in subdirectory

I have the following folder structure in my git repository:
/
/MyApp
/MyApp/app
/MyApp/bin
/MyApp/...
/MobileClient
MyApp is the Rails application (directory) which I'm trying to deploy using AWS OpsWorks. The MobileClient directory is just as it sounds.
I'm deploying via git (also, set the Document Root setting to MyApp/public) however the deployment fails and I'm also seeing on the machine that the generated config, log and public directories are on the root level instead of being in the subdirectory.
Is there a simple way of using a git deployment for a Rails app which resides in a subdirectory?

Rails 4.2 capistrano 3 deployment

I am totally new to rails deployment. After googling, I still find it hard to understand how to deploy rails apps.
So, my questions are:
After setting up the VPS with all rails dependencies, where do I store my codebase? The root directory of the VPS or some specific locations e.g. www/ or public/?
Should I upload the whole rails app folder or just part of it? I have paperclip in my rails app, and paperclip creates a system/ directory in the public/ folder, so should I upload system/?
In Capistrano 3, there is a repo_url field, I know they support file://, https://, ssh://, or svn+ssh://, but most of the articles about capistrano put github repositories into that. However, I do not have such a github repo. What should I input then?
Thank you for your attention.
Answers to the specific questions raised:
After setting up the VPS with all rails dependencies, where do I store
my codebase? The root directory of the VPS or some specific locations
e.g. www/ or public/?
It will be deployed to the folder pointed by :deploy_to parameter. If not specified, :deploy_to defaults to /var/www/#{fetch(:application) See: https://github.com/capistrano/capistrano/blob/05f63f5f333bb261f2a4c4497174361c48143252/lib/capistrano/defaults.rb#L3
Should I upload the whole rails app folder or just part of it? I have
paperclip in my rails app, and paperclip creates a system/ directory
in the public/ folder, so should I upload system/?
Paperclip system folder is specific to the environment; each environment (development, production,...) will have its own system folder which will store the files uploaded on that specific environment. This folder should not be part of the code being deployed.
The recommended way of handing such folders is the keep them in a shared folder on the server, and create symlinks in the current version of the code so that the same folder is used for storing/retrieving attachments. See Section 3. Update custom links section in http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano for more details about this.
As mentioned there, the same applies to config/database.yml file, and any other file containing environment specific configurations.
In Capistrano 3, there is a repo_url field, I know they support
file://, https://, ssh://, or svn+ssh://, but most of the articles
about capistrano put github repositories into that. However, I do not
have such a github repo. What should I input then?
Depends on where the code you are deploying is stored. If it is in a local folder, use the file::// format to specify where the files are located.
You can set up your own private git server, then in deploy.rb you can put something like
set :repo_url, 'ssh://user#server_ip/path/to/your_git_repo.git'
When you commit your changes to the git repo, you do not have to upload the app to the server. Capistrano will upload the app for you when you deploy.
where do i put my code base? This is determined by what you put in deploy.rb e.g
set :deploy_to, '/path/to/my_codebase'
Whether to upload the /system directory will depend on whether you want the paperclip images on your version control. If not you can add the directory to gitignore. Here is a tutorial on how to deploy on ubuntu 14.04 passenger and NGINX. if you are not using Passenger and Nginx you can skip to how to configure capistrano and make adjustments depending on your setup.
EDIT
You need to install git on your development machine and set up a git server on your VPS as explained on the link above, add your remote server to your local machine using
git remote add origin <server>
where 'server' is the url to your git repo in the VPS e.g.
ssh://VPS_user#VPS_ip/path/to/your_git_repo.git
Now when you commit and push your changes to the server, capistrano will deploy the latest version on your git server.
Here is a link with a guide on how to get started with git

Is it a bad idea to put apache conf files in my rails app's config directory?

I have a dedicated CentOS server. I manage all my users, apps, and virtual hosts manually. I'm using Apache 2.2.3 and Passenger 3.0.7 to serve my apps. I have a typical httpd.conf file in /etc/httpd/conf/ that includes all *.conf files in my /etc/httpd/conf/vhosts/ directory. Normally for each app I create a new sample-domain.com.conf file in the vhosts directory.
However, I have a particular app that needs frequent apache configuration changes, and I'd like it to be more a part of my app and its version control. So I've moved my apache configuration file into the apps config directory. I added a script to my Capistrano deploy.rb that sets the permissions on the apache conf file in the app to 755. I added an include line in my vhosts that includes the symlinked current version of the apache conf file from the app.
Which brings me to my simple question: is this safe or a bad idea?
For frequent config changes in Apache, consider using a .htaccess file instead. Changing .conf files requires bouncing/hupping the server, and if a .conf file has an error, that'll kill the whole server and take down all sites. A .htaccess error will take down just the one site/directory where the file is.

Deploying a .war made by Warbler to Tomcat

I was trying to simply make a .war file and put it into Tomcat's webapps directory. Simple, right? :)
What is puzzling me is that the directory structure of a JRuby app has the index.html file somewhere far in the application structure and Tomcat just can not find it by default.
Here is what I get when I point my url to the Tomcat install of the application:
http://128.48.204.195:8080/blog/index.html
How should I structure the build/deploy of a JRuby application so that it works on Tomcat when unwrapped out of a .war file?
first try http://128.48.204.195/blog
that will serve the root route (if defined in config/routes.rb) or a error saying nor route.
If you see this: http://krokinet.files.wordpress.com/2010/11/rails-welcome1.png
there is a default index.html file in /public/index.html
that file is generated with the app and you should remove it once your done an initial 'smoke test' (running your newly generated app the first time).
More information on the root route here: http://edgeguides.rubyonrails.org/routing.html#using-root

Resources