Add rake docker tasks

This commit is contained in:
Thor77 2019-04-17 08:22:17 +02:00
parent fa6b3545f9
commit 201f08f09c
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 28 additions and 0 deletions

28
lib/tasks/docker.rake Normal file
View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
IMAGE_NAME = 'turniere/backend'
namespace :docker do
desc 'Build docker image'
task :build, [:tag] do |_, args|
args.with_defaults(tag: 'latest')
sh "docker build -t #{IMAGE_NAME}:#{args.tag} ."
end
desc 'Tag docker image with Travis build number'
task :tag do
next if ENV['TRAVIS_PULL_REQUEST'] != 'false'
tag = "build#{ENV['TRAVIS_BUILD_NUMBER']}"
sh "docker tag #{IMAGE_NAME} #{IMAGE_NAME}:#{tag}"
end
desc 'Push docker image'
task :push do
sh "docker push #{IMAGE_NAME}"
end
desc 'Run TravisCI tasks'
task travis: %i[build tag push] do
end
end