Git / Rails / shared hosting (Dreamhost)

This is primarily a question of making good use of Git. I must first say that I am not an expert in Rails (at least in the production sense) and definitely a newbie to Git, however, I had some experience using SVN.

My problem is that I am trying to create a rails application, but I don’t know how best to support local localization on my computer, but to be able to deploy my Dreamhost hosting account.

I realized that Git would let me do this, but I'm not quite sure how to do this. I was thinking of creating a repo on Git on the server, and after each commit, local files were pressed on it. I read a few Git tutorials, but I'm still confused about what to do. An alternative to this would be to simply use FTP and copy files, but this does not seem to be correct.

Does anyone have a few first steps and / or commands that I can use? Is this deployment method suspicious or is there a better way to do this?

+4
source share
3 answers

I launched the Rails website for a Wisconsin brass band in a very similar setting to what you are describing, although it currently works with hostingrails.com. I post my code on github , although there is no reason why you could not post it privately. My flow has evolved over the past year and a half, so take from it only what you need in the short term.

At the center of my thread, I installed a semi- developed Capistrano script to handle the deployment, including a separate staging environment that makes a whole copy of the database for testing. It took some time (hours, not days) to build, but it was so worthy.

My workflow stores at least 2 branches :

  • current_release : Live code. Errors are fixed here.
  • master : Ready-made functions are ready for release. These features are waiting here to test live. Bugs fixed with error from current_release .
  • <feature_name> : Developed features. I try not to have more than three of them at any given time. Emergency fixes are combined, and master often combined to save the current function.

Having this setting allows me to work on several things at the same time. Week-to-week (since this is nowhere suitable for full employment), I do the following:

  • I am editing in function branches. I switch back and forth, miss, worry, whatever. Sometimes I combine two functions that grow together.

    [edit]
    $ git commit
    $ git push github [feature]

  • Ready-made functions ready for simulation deployment are merged once into the master branch.

    $ git checkout master
    $ git merge [feature]
    [fix immediate problems or inconsistencies]
    $ git commit
    $ git push github master
    $ git branch -d [feature]

  • I host the site in a private URL (for example, stage.madisonbrass.com). The environment is always pulled from the master branch.

    <code> $ cap staging deploy # master now live on stage.madisonbrass.com Code>

  • Bam, while I'm testing, I find a crash error on a public website. Fortunately, I have current_release working separately, and therefore, you can fix and deploy it separately.

    $ git checkout current_release
    [fix bug]
    $ git commit
    $ git push github current_release
    $ cap production deploy

  • I return to the master branch and start by merging the disaster fix.

    $ git checkout master
    $ git merge current_release

  • I continue testing master . I hope no new problems arise, but if they do, I will fix them in master, I will merge these changes into current_release and do another production deployment.

    $ git checkout current_release
    $ git merge master
    $ git push github current_release
    $ cap production deploy

  • I will tear my intermediate environment so that it is somehow not indexed by the search engine.

    $ git staging teardown

+8
source

I have a general, open Git repository (created using git init --shared --bare ), which is the "main" repository, and that is where I push my work. The bare repository does not have a working directory. For my web directory, I am cloning a master repository, so it has a working directory and all the files are there. From there, I git pull any new work that I have done.

I always work on development on a separate machine with a repository clone and test development environment. When I finished the function, I push it to the wizard, and then we go to the working server and pull it into the working directory.

It's just me for not very important projects. This could be expanded with many additional steps and checks and weights for important work.

+4
source

I would recommend using GitHub and keeping Dreamhost resources as free as possible in order to run the Rails application (in fact, depending on your project, I need as much as it will have to turn over with it, being shared hosting).

My normal workflow has a development environment and a GitHub account. We use Capistrano (which is simple enough to learn and understand) to control the click on GitHub, and then deploy accordingly to the hosting in your case Dreamhost via SSH / SCP.

This way, you don’t have to worry about what is actually in your production repository and you don’t have to perform maintenance tasks on it. It works very fast and can be easily adapted when you decide to change server hosts.

0
source

All Articles