Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Build syslgen docker image using travis (#2)
Browse files Browse the repository at this point in the history
* Add image build script
* Modify secure variables, refactor build script
* Standardize command-line syntax
  • Loading branch information
Kasun Fernando authored Apr 2, 2019
1 parent dad4c86 commit 37d3406
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: generic
sudo: false
services:
- docker
env:
global:
- secure: aUTKskuviFRSkvG9ikwklunjx1EYEv8Veqa8EK7LrQIz87D8y9tqeuEhxHsVlg2MrAcNPisidgrv77RADe0rz95pwkv8B1AvR9H0Mji8OfQzzsjXHsrWoBteJCkmb5RZ8mcwLjZLeVZDIgkDLaKzGXy43+qZO3sCzZSDfUahVXQM3AbrlLTwlVhOeFlmI7yDWWAKBCzQQqVVd0ACWAjMWQcjeIwgJTGDN8eKXkO8wkgFq7HKhp/6GiMiIZEd2Rto93rotfmhgKyNWhSTUxkrQk+WnHTQo4YBTdJ3phtDSCwJaOvUdAXf0xQv4NOAAq1cE1fVKGxlLFVrK2ouXs1SkQYTdACkaDP/dBHzEnglQmUGz7n08K9cpLVBDdPnfumW8uzbD65ZnuTAitgAJ+j3n/Qi6Gw6etImmogDa+w2HhUCxg6Vst4Uat3BGbnh+KvMyULJKpzDiHLDalmj1r4Q4q+mL7ZspxpUkzqndoaXiFdD9xaTr7siHPOxRLt2h/zpNTzlyd5yFQGpnxFY+tRD0AnOcn+YkiUTLFmFhP49fLG+LyiEhYYSZsagE6nCy1CS0P+ZC7K0ffAWExlMtxuptGJz8r8ruPCmLC/EP6yxPKS5AwmBGnJLD+MZy6k5W/W4Mow0ONwIqrqAcp3j8asGyz85xbsiM2nil20erF2IHyA=
- secure: ii/U6ZrhwsaOD7XRgS3S8j4sECY97ruy26LFs7uh3o1ujZeeFGEKINzSC6xNqXeJ0bbmb82Wit1NGGvW4VrLooQyoj2vzQPeb2PdAaaN2OzamEkJymIARf7RoVbzhJkT4Z2SvrQz9tRwUNg8waLfTUnA0t5xpe6qbrz4IWJ6+SzGCEVyRRoon6Vi2tD2LeYZUfrc6CFSbLSv9BU1dpSDEyV0VhA0MtKgDRmgh4P03kyiDGoZVN8Ndy04trUUHsHVfnJOnMTU9ocI/6QuTGiOC9vI8jXJwl2fkpWI6p2YHmDbYTIAxfHfU3A2AvBmabJuqwUXJ2U8Ieu4ctTlzlZ5Tr7qG70/ZKqjzXdQnkU0ICqqtrKWjT+1/NtWsCHI257Fdg/ytEmH4ZgsCN1oGH3tdN3m7JXgEEjPXovm5ZdX0hN0nFgZbXbzPguii5VRUtYl76c71JVZbcxUDj0Mdj2OOxkMIAG4WUtumX4yiybZbHmwXuETTiILnY08emRiyK1rx0Jgydw1eKI2RxJUDSyo7jJYsD+NLm5JO8YmflSNYrdCJZsZiyKaaLpvTNZ4J3j+01XnnKpyYkzhnDjmv7JeKw0tarRBvVj3Tgy3YEZiONIXuDrurGEz6/wq0ctN0gT21zXTO1vOzvJ0qud14cuRJ7g9Z/jQ6xRFag0zUkrUF2g=
before_deploy:
- sh build-image.sh ${TRAVIS_TAG} build
deploy:
- provider: script
script: docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" && sh build-image.sh ${TRAVIS_TAG} deploy
on:
repo: anz-bank/syslgen-examples
tags: true
condition: "$TRAVIS_OS_NAME = linux"
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG SYSL2_VERSION

FROM anzbank/sysl2:${SYSL2_VERSION}

ENV SYSLGEN_BASE=/syslgen-examples
COPY . .
42 changes: 42 additions & 0 deletions build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

set -e -x

TAG=$1
COMMAND=$2

usage() {
echo "Usage: sh build-image.sh <tag> (build|deploy)"
echo "eg: sh build-image.sh 0.0.1 build"
}

if [ -z "$TAG" ]; then
echo "Tag is not specified."
usage
exit 1
fi

if [ "$COMMAND" != "build" ] && [ "$COMMAND" != "deploy" ]; then
echo "Invalid command or command not specified."
usage
exit 1
fi

SYSL2_VERSION=0.2.5-ubuntu18.04
DOCKER_IMAGE="anzbank/syslgen-examples"
DOCKER_IMAGE_VERSIONED="$DOCKER_IMAGE:${TAG}"

build() {
docker build --build-arg SYSL2_VERSION=$SYSL2_VERSION -t "$DOCKER_IMAGE" -f Dockerfile .
docker tag "$DOCKER_IMAGE" "$DOCKER_IMAGE_VERSIONED"
}

deploy() {
docker push "$DOCKER_IMAGE_VERSIONED" && docker push "$DOCKER_IMAGE"
}

if [ "$COMMAND" = "build" ]; then
build
elif [ "$COMMAND" = "deploy" ]; then
deploy
fi

0 comments on commit 37d3406

Please sign in to comment.