Skip to content

Docker Hub Travis CI Workflow

Jean-Michaël Celerier edited this page Jun 3, 2016 · 9 revisions

This page explains how to build and deploy AppImages from Travis CI, using Docker.

The objective is to have a pipeline that automatically build a binary working on most recent desktop distributions, and upload it to github releases or a provider of your choice.

This tutorial assumes familiarity with the creation of AppImages.

Prerequisites

First, multiple things are required :

  • A GitHub repository with a program that you want to embed in an AppImage.
  • A Travis CI account. Travis is a continuous integration service. It provides virtual machines for open source projects that are triggered on each new commit in the GitHub repository.
  • A Docker Hub account. This optionally allows uploading pre-built Docker images, in order to reduce the build time on Travis. It is also useful if no images provide the packages you need (for instance, if you need a really recent version of GCC, Qt or Clang, or a system library with specific build options).

Creation of a Docker image

The first thing to do is to set-up your AppImage on an old system, for instance CentOS.

This can easily be done with docker :

$ docker pull centos:6
$ docker run -i -t centos:6 /bin/bash

These commands drop you to a shell running in a CentOS container. From there, you can update, install more recent packages, etc :

# yum -y update 
# yum -y install epel-release

epel-release is a repository that contains very recent versions of some packages. For instance, it provides Qt 5.6. This is useful for modern development toolchains.

Write down all the commands used to "populate" the container in a script, this is useful for rebuilding it automatically if more updates come down the pipeline. For instance :

Recipe.deps

#!/bin/bash -eux 

yum -y install epel-release
yum -y update 
yum -y install qt5-qtbase-devel gcc gcc-c++

[ ... git clone AppImage, AppImageKit, etc. ...]

Then, write your AppImage recipe and try it on the container (and try to build to to check that everything works !). The recipe should clone or pull the repository, build the software, and ends by creating the AppImage : once it is run, there should be a folder with YourSoftware.AppImage somewhere.

Recipe

#!/bin/bash -eux

git clone https://github.com/my/software
cmake, etc...

Examples of recipes : https://github.com/probonopd/AppImages/tree/master/recipes

Finally, we create a Docker file that explains how to build the image :

Dockerfile

FROM centos:6

ADD Recipe.deps /Recipe.deps
RUN bash -ex Recipe.deps 

ADD Recipe /Recipe
RUN bash -ex Recipe

Once done, you can do a test build of the container :

$ docker build -t my_image .
$ docker create --name my_container my_image

You can see the container id with docker ps. The created AppImage can be copied to the host with docker cp :

$ docker cp my_container:/path/to/created.AppImage created.AppImage 

Try it :

$ ./created.AppImage

The docker container can then be uploaded to Docker hub :

$ docker tag my_container  dockerhub_user_name/my_container:latest
$ docker push dockerhub_user_name/my_container:latest

The built image is uploaded to Docker hub; you will be able to pull it from Travis CI.

Travis set-up

Some options are necessary, as of june 2016, to use Docker in Travis:

.travis.yml beginning

sudo: required
services:
  - docker

script: 
  - docker pull dockerhub_user_name/my_container
  - docker run --name buildvm dockerhub_user_name/my_container /bin/bash Recipe
  - docker cp buildvm:/path/to/created.AppImage created.AppImage 

I

Clone this wiki locally