Cloud Foundry logo in white on a blue background
blog single gear
Tutorials

100-day Challenge #051: Running Camaleon CMS on Cloud Foundry

Translator’s note: This is the 12th article of the series “Cloud Foundry 100-day Challenge selection”. “#051” in the title means that it is 51st (published on September 1, 2015) in the original Japanese series.

Original Author: Jun HORIUCHI (GitHub) (company)


The 51st topic of “Cloud Foundry 100-Day Challenge”, and the first topic of the second half, is Camaleon CMS , a Ruby-on-Rails based CMS. It may come in handy when, for example, you want to launch a simple website for private use.
However, there are some restrictions that need to be kept in mind, due to the characteristics of Cloud Foundry. We will go further into that later in the supplemental section.

Basic Information

The procedures from deployment preparation to testing is as follows:

  • 1) Retrieving source code
  • 2) Deployment
  • 3) Checking application behavior

1. Retrieving source code

Let’s clone the source code from GitHub.

$ git clone https://github.com/owen2345/camaleon-cms.git
$ cd camaleon-cms
camaleon-cms$ ls
app  app.json  bin  config  config.ru  db  Gemfile  Gemfile.lock  lib  license.txt  public  Rakefile  README.md  test  vendor

2. Deployment

First, we create a database for Camaleon CMS.
In the Requirements of the README, we find ‘MySQL5 or Sqlite or PostgreSQL’, so we will launch with PostgreSQL today.
Let’s go ahead and create a PostgreSQL service. If there is no PostgreSQL service broker in the bosh-lite environment you are using, please add it in advance using “100-day Challenge #002: Running postgresql-cf-service-broker on Cloud Foundry” as reference.

camaleon-cms$ cf create-service PostgreSQL 'Basic PostgreSQL Plan' came-pg
Creating service instance spwd-pg in org horiu-jn / space horiu-jn as horiu-jn...
OK

Next, let’s create a manifest file for the deployment.

camaleon-cms$ vi manifest.yml
applications:
- name: came-100
  memory: 1G
  command: 'RAILS_ENV=production bundle exec rake db:migrate && bundle exec rackup --port $PORT'
  services:
    - came-pg
  • It did not start up when we had tried deploying the application with memory size of 256MB, so today we specified ‘memory:’ to be ‘1G’ for extra margin.
  • There are actually no content in db/seeds.rb, therefore we specify only ‘db:migrate’ in ‘command:’, as operation for the database.
  • When we specify the name(s) of the service(s) to be bound in ‘services:’, the binding operation(s) will automatically be executed when ‘cf push’. Thus we will do so.

Once the manifest file is complete, let’s push the application.

camaleon-cms$ cf push
Using manifest file /home/horiu-jn/workspace/apps/camaleon-cms/manifest.yml
 
Creating app came-100 in org horiu-jn / space 100nichi as horiu-jn...
OK
 
Using route came-100.10.244.0.34.xip.io
Binding came-100.10.244.0.34.xip.io to came-100...
OK
 
Uploading came-100...
Uploading app files from: /home/horiu-jn/workspace/apps/camaleon-cms
Uploading 5.3M, 1341 files
Done uploading
OK
Binding service came-pg to app came-100 in org horiu-jn / space 100nichi as horiu-jn...
OK
 
Starting app came-100 in org horiu-jn / space 100nichi as horiu-jn...
 
:
 
0 of 1 instances running, 1 starting
1 of 1 instances running
 
App started
 
 
OK
 
App came-100 was started using this command `RAILS_ENV=production bundle exec rake db:migrate && bundle exec rackup --port $PORT`
 
Showing health and status for app came-100 in org horiu-jn / space 100nichi as horiu-jn...
OK
 
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: came-100.10.244.0.34.xip.io
last uploaded: Thu Aug 20 06:47:26 UTC 2015
stack: cflinuxfs2
buildpack: Ruby
 
     state     since                    cpu    memory           disk      details
#0   running   2015-08-20 03:49:27 PM   0.0%   172.7M of 256M   0 of 1G

The deployment is successful.

3. Checking application behavior

Let us access the URL for the application, which we obtained above, from a Web broswer.

A website will be created when we enter a site name into ‘Name’ and click on ‘Submit’, and then the account information for “admin” will be displayed.

We get the log in screen when we click ‘Visit Admin Panel Here’.
We also get the site administration dashboard when we input the “admin” account information and log in.

Various operations can be conducted from the menu on the left, such as posting to the site, uploading files, adding users, etc.
We cannot go through all of the functions here, so we will focus on posting to the site.

Let’s select ‘Content > Post > Add New’ from the Select menu, and obtain the screen with the form for creating articles.
It took us a while to get this screen; please be patient and give it some time.
When you get the screen, please enter all information that is denoted as ‘required’, and click ‘Create’.

If successful, the created article should appear in the list of articles that is displayed with ‘Content > Post > All Items’

Let us take a look at a page from this site. You can obtain the page by selecting ‘Visit’ from the pull-down menu at the top of the window.

We find that the posted article is displayed in the page as it is supposed to be.

Supplemental information

In Camaleon CMS, articles, user information, settings information, etc. are managed in a database. However, uploaded files such as images and documents are managed in a file system within the container where an instance of the application is running. Therefore, these files will be lost when the instance is regenerated due to an application reboot, with ‘cf restart’ etc.

[before cf restart]

[after cf restart]

After ‘cf restart’, the image is no longer displayed.

If you wish to operate Camaleon CMS while managing files persistently, you will need to consider how to achieve persistence, and modify Camaleon CMS.

Software Used in this Post