.. Copyright 2014 tsuru authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +++++++++++++++++++ Creating a platform +++++++++++++++++++ Overview ======== If you need a platform that's not already available in our `platforms repository `_ it's pretty easy to create a new one based on an existing one. Platforms are Docker images that are used to deploy your application code on tsuru. tsuru 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. An example ========== Let's suppose we wanted to create a nodejs platform. First, let's define it's Dockerfile: .. highlight:: bash :: FROM tsuru/base-platform ADD . /var/lib/tsuru/nodejs RUN cp /var/lib/tsuru/nodejs/deploy /var/lib/tsuru RUN /var/lib/tsuru/nodejs/install In this file, we are extending the ``tsuru/base-platform``, adding our deploy and install scripts to the right place: ``/var/lib/tsuru``. The install script runs when we add or update the platform on tsuru. It's the perfect place to install dependencies that every application on it's platform needs: .. highlight:: bash :: #!/bin/bash -le SOURCE_DIR=/var/lib/tsuru 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 <