Reputation: 19478
I have a git repository that contains a simple web application. The web application is run as a typical Scala application (I use unfiltered to be specific). In other words, I can run the web application in production with "sbt start".
I would like to have an easier way of deploying updates to the web application. I have been creating an assembly, copying it to the server, manually stopping the old server, and starting a new server instance.
My thought is to have a new remote repository web
that pushes directly to the production server. I could then add a post-receive
hook on the production git repository that kills the old server and starts a new one.
Is this a reasonable set up for automated deployment? Are there any tools to help do this with sbt
and git
?
Upvotes: 1
Views: 149
Reputation: 2989
I usually deploy PHP applications using Git hooks. Basic idea is, that from post-update hook is executed update of second (non-bare) repository and checkout of the new version. After that, update script updates database and sends me an e-mail.
You can use this approach with minimal changes. Clone your repo to build area on web server and make a script, which will:
git fetch origin
).git checkout --force master && git reset --hard
or something like that, just to make sure it will always succeed).Then run this script from post-update hook in origin repo. Nothing complex here.
Upvotes: 1
Reputation: 658
https://rubygems.org/gems/git-runner
It's a ruby gem (you don't need to be using Ruby in your app to utilise this) to perform tasks after pushes to a git repository. You can then write your own classes to perform the deploy tasks that you need (or look at using/modifying the existing git-runner-deploy gem). That might fit your bill, though perhaps you'd feel happier using that if you're already using ruby somewhere in your process?
Upvotes: 0
Reputation: 33451
Yeah, your solution is good for simple cases. But it scales bad, because when your software become more complicated, you need to change hooks in imperative way.
Take a look at one of Continuous Integration servers (Jenkins or Travis are good points to start). Using CI servers allows you to use declarative approach, when you just specify the results you need. CI server takes care of most of your tasks: fetching the latest code from the repo, building it, testing, packaging, deploying, sending emails. Also, it will be useful when working with team in parallel branches. Summarizing: CI brings scalability to your build process, when growing complexity of your codebase does not interfere with you deploys.
Upvotes: 1