Skip to content

Commit

Permalink
Merge pull request #215 from rporres/add-ci
Browse files Browse the repository at this point in the history
Travis to push on tag
  • Loading branch information
numeroteca authored Nov 13, 2018
2 parents 7057429 + 6c1be55 commit 2cd70b0
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 9 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 32 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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.