How to create a bosh release to publish an static web site

by Gastón Ramos

0- Purpose of post.

In this post I’ll show you how to create a bosh release to serve an static web page, for this I will use bosh-lite which is a version of bosh for development and bosh-gen which is a bosh release generator.

1- Bosh-lite and Bosh-gen and create the release.

Let’s see a little the help the bosh-gen. As we can see we can do several things, let’s start creating our release to be called “static-syte”

==> bosh-gen new static-syte

00-bosh-new

2- Download apache2 sources and create the package for apache

We just created our release now we have to download the sources of our web server and put them in the folder src/. You can download apache from this url: https://httpd.apache.org/download.cgi

I already downloaded apache 2.2.25 and staved in ~/Downloads dir.

  => cd static-site
  => mkdir -p src/apache2
  => cp ~/Downloads/httpd-2.2.25.tar.gz src/apache2

Done this we need to create our first package for apache

=> bosh-gen help package

01-bosh-help-package

=> bosh-gen package apache2 -f src/apache2/httpd-2.2.25.tar.gz

We are going to build the package from the sources so we don’t need the blob

=> rm blobs/apache2/httpd-2.2.25.tar.gz

3- Take a look into packaging and spec files

As we can see has created 2 files spec and packaging, packaging is the script that contains the instructions for building our package. Spec contains among other things the dependencies and files needed to compile our package.

4- Create httpd Job

We created our bosh package now need to tell which is the process that we need to run to lift our web server and what settings it needs, for this we have to create a job

=> bosh-gen job httpd

03-bosh-gen-job

5- Take a look into monit, httpd_ctl and spec files

As we can see it created some files, but let’s focus only on spec and monit files,
monit file basically has the data that monit needs to start and stop the job, in this
case it uses a helper script created by bosh-gen to help us debug our job.
To change the start command for this new job we need to edit httpd_ctl template.

Edit the jobs/httpd/templates/bin/httpd_ctl comment the pid_guard and add the start command by this:
/var/vcap/packages/apache2/bin/apachectl start  

after that it should look like this:

04-edit-ctl-template

Edit monit file and change the pid file location to /var/vcap/packages/apache2/logs/httpd.pid

after that it should look like this:

05-edit-monit

6- Create release manifest file

We have a package (the bits needed to run our server) and the job (the configurations and scripts to lift the web server process) now we need to create and upload our release.

==> rm config/private.yml 
==> git add .
==> git commit -a -m "added package apache2 and job httpd"
==> bosh create release
06-bosh-create-release
 07-bosh-create-release-b
==> bosh upload release

08-bosh-upload-release
09-bosh-upload-release-b

7- Create deploy manifest file

 ==> bosh-gen manifest httpd .

10-bosh-gen-manifest

Then we need to point bosh to this deployment file:

bosh deployment httpd.yml

and let’s do our first deploy

bosh -n deploy

11-bosh-deploy
12-bosh-deploy

If we open a browser we will se the apache default page like this:

14-apache-default-web

So yeaaaah, we just did our first deploy!!! but this page is not so funny and we need to have the might, the muscle to show our own site!
In the next post i will show you how to add a new package for our cool static page.

stay tuned will continue…