The Shipa Developer Hub

Welcome to the Shipa developer hub. You'll find comprehensive guides and documentation to help you start working with Shipa as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Changelog

Creating a Platform

In case there is a requirement of a platform that’s not already available in Shipa's platforms repository, Shipa makes it quite easy to create and add new ones, utilizing current and existing platforms as a base.

Platforms are Docker images that are used to deploy your application code on Shipa. Shipa provides a base image which platform developers can use to build upon: base-platform. This platform provides a base deployment script, which handles package downloading and extraction in proper path, along with operating system package management.

Every platform in the repository extends the base-platform adding the specifics of each platform. They are a great way to learn how to create a new one.

Sample Platform Creation

For the example below, we will create a nodejs platform. First, let’s define it’s Dockerfile:

FROM  shipa/base-platform
ADD . /var/lib/shipa/nodejs
RUN cp /var/lib/shipa/nodejs/deploy /var/lib/shipa
RUN /var/lib/shipa/nodejs/install

In the file above, we are extending the shipa/base-platform, adding our deploy and install scripts to the right place: /var/lib/shipa.

The install script runs when we add or update the platform on shipa. It’s the perfect place to install dependencies that every application on it’s platform needs:

#!/bin/bash -le

SOURCE_DIR=/var/lib/shipa
source ${SOURCE_DIR}/base/rc/config

apt-get update
apt-get install git -y
git clone https://github.com/creationix/nvm.git /etc/nvm
cd /etc/nvm && git checkout `git describe --abbrev=0 --tags`

cat >> ${HOME}/.profile <<EOF
if [ -e ${HOME}/.nvm_bin ]; then
    export PATH="${HOME}/.nvm_bin:$PATH"
fi
EOF

On the code above, dependencies are being installed and the environment prepared for the applications.

The ${SOURCE_DIR}/base/rc/config provides some bootstrap configuration that are usually needed.

The next step is to define the deploy script, which runs every time a deploy occurs:

#!/bin/bash -le

SOURCE_DIR=/var/lib/shipa
source ${SOURCE_DIR}/base/rc/config
source ${SOURCE_DIR}/base/deploy

export NVM_DIR=${HOME}/.nvm
[ ! -e ${NVM_DIR} ] && mkdir -p ${NVM_DIR}

. /etc/nvm/nvm.sh

nvm install stable

rm -f ~/.nvm_bin
ln -s $NVM_BIN ~/.nvm_bin

if [ -f ${CURRENT_DIR}/package.json ]; then
    pushd $CURRENT_DIR && npm install --production
    popd
fi

On the code above, we run some base scripts to do some heavy lifting: ${SOURCE_DIR}/base/rc/config and ${SOURCE_DIR}/base/deploy.

After that, it’s just a matter of application specifics dependencies using npm.

Adding Newly Created Platforms

After creating a platform as a Dockerfile, users can add it to Shipa using Shipa's client package:

$ shipa platform-add your-platform-name --dockerfile http://url-to-dockerfile

If the image is pushed to a Docker Registry, users can use:

$ shipa platform-add your-platform-name -i your-user/image-name

Updated 10 months ago

Creating a Platform


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.