DEV Community

Sushant Bajracharya
Sushant Bajracharya

Posted on

4

Deploy static site via Capistrano

At work, I was working on a PTE project. The frontend was in vuejs and the backend was in rails api. As usual, we deployed the backend with capistrano.

For frontend, my boss wanted it to be deployed just like capistrano did, with a release folder, shared folder, rollbacks, etc. He also wanted only the compile folder to go in the server and not the whole repo.

I looked into a couple of tools that deployed static site but I could not wrap my head around it.

Since I knew capistrano and have been using it for all of my projects I decided to use it to deploy the frontend. I created a gem called Static which is an SCM plugin for capistrano.

How to use it?

Create a gemfile in your project's folder.

# Gemfile.rb

group :development do
 gem "capistrano", "~> 3.10", require: false
 gem 'capistrano-scm-static', '~> 0.0.2', require: false
end

Then run bundle exec cap install . It will install all the necessary files and folder in your project.

# Capfile

require 'capistrano/scm/static'
install_plugin Capistrano::SCM::Static

# deploy.rb
set :dist, 'path to your static template compilation folder'

Let's say you are working with reactjs on frontend then your compilation folder will be build, so just set

set :dist, 'build' # in case for reactjs

If you are working with vuejs

set :dist, 'dist' # in case for vuejs

To deploy it, run cap production deploy or if your have set other environments, then cap <environemnt> deploy

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more