-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from rporres/add-ci
Travis to push on tag
- Loading branch information
Showing
2 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |