Search code examples
perlmojolicious

Best way to package and deploy mojolicious apps


I am looking to combine Mojolicious, perlbrew and carton to deploy an app into a live environment. Have access to Jenkins, so can package the app as an rpm or could update codebase via a git pull.

Really looking for deployment strategies that make the process as simple as possible.

Does anyone have any experience of using these tools together?

We are running mojo via hypnotoad and might place it behind an apiaxle proxy.


Solution

  • We have a system at work that automates this; I can't share the code, but I can summarize.

    1. We maintain our projects in git, and our deployables in a separate git repo (one per jenkins job, e.g. project-dev, project-qa, etc.).
    2. We maintain our list of dependencies in a cpanfile and keep them up-to-date in our checkouts using carton install.
    3. After creating a project, and whenever dependencies change, we commit cpanfile.snapshot.
    4. The jenkins job checks out the source repo and runs carton install --deployment (actually it runs a script in each repo that does that plus any other necessary build tasks for that project).
    5. Tests and such are run.
    6. If this is the first jenkins build, it copies the whole tree (including the local directory created by carton, but excluding .git) to a new directory, git inits it, creates a new commit, and pushes it to the deployment repo.
    7. Otherwise, it checks out the last successful build from the deployment repo in a new directory, rsyncs the contents of the build tree (excluding .git) onto the deployment tree, does a git add --all and commits, and pushes it as a new build.

    In all cases the build is pushed to the deployment repo as a branch named after the build number. Then the deployment tool can ask jenkins for a list of successful builds, and deploy a build by having the servers do git fetch ; git reset --hard origin/$BUILDNUMBER in a checkout of the deployment repo.