Permalink
Browse files

Merge pull request #215 from rporres/add-ci

Travis to push on tag
  • Loading branch information...
numeroteca committed Nov 13, 2018
2 parents 7057429 + 6c1be55 commit 2cd70b09b37a923f21e8ce508e62e04f99567301
Showing with 63 additions and 9 deletions.
  1. +31 −0 .travis.yml
  2. +32 −9 Makefile
@@ -0,0 +1,31 @@
dist: trusty

language: ruby

rvm:
- 1.9.3-p551

bundler_args: --without heroku

sudo: required

services:
- mysql

stages:
- name: release
if: tag IS present

before_install:
- sudo apt-get update
- sudo apt-get install -y libxml2-dev
- gem update --system
- gem install --force bundler
- gem install debugger-ruby_core_source

jobs:
include:
- name: 'Push image to Docker Hub'
stage: release
script:
- make docker-push
@@ -1,13 +1,36 @@
# TODO: This is temporary, will need to adjust it when we connect to
# a proper CI
PROJECT = pageonex
DOCKER_REGISTRY = docker.io
DOCKER_ORG = pageonex
VERSION := $(TAG)
DOCKER_IMAGE = $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):$(VERSION)
DOCKER_REGISTRY ?= docker.io
DOCKER_ORG ?= pageonex
DOCKER_USERNAME ?=
DOCKER_PASSWORD ?=
VERSION ?= $(TRAVIS_TAG)

docker-login: docker-validate
@docker login -u "$(DOCKER_USERNAME)" -p "$(DOCKER_PASSWORD)" $(DOCKER_REGISTRY); \

docker-validate:
@if [ -z "$(DOCKER_USERNAME)" ]; then \
echo "DOCKER_USERNAME variable cannot be empty."; \
exit 1; \
fi; \
if [ -z "$(DOCKER_PASSWORD)" ]; then \
echo "DOCKER_PASSWORD variable cannot be empty."; \
exit 1; \
fi

docker-build:
docker build -t $(DOCKER_IMAGE) .
@if [ -z "$(VERSION)" ]; then \
echo "VERSION variable cannot be empty."; \
exit 1; \
fi; \
if [ -z "$(DOCKER_ORG)" ]; then \
echo "DOCKER_ORG variable cannot be empty."; \
exit 1; \
fi; \
docker build -t $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):$(VERSION) .; \

docker-push: docker-build
docker push $(DOCKER_IMAGE)
docker-push: docker-login docker-build
docker push $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):$(VERSION); \
docker tag $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):$(VERSION) \
$(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):latest; \
docker push $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT):latest;

0 comments on commit 2cd70b0

Please sign in to comment.