Commit 890748e4 authored by echel0n's avatar echel0n

Added Grunt task to build and push docker images.

parent df15c000
FROM python:3.7.2-alpine3.8
MAINTAINER echel0n <[email protected]>
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT $SOURCE_COMMIT
RUN echo "SOURCE_COMMIT = $SOURCE_COMMIT"
ENV TZ 'Canada/Pacific'
# install app
......
const webpackConfig = require('./webpack.config');
module.exports = function (grunt) {
const shell = require('shelljs');
const webpackConfig = require('./webpack.config');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
......@@ -47,6 +48,26 @@ module.exports = function (grunt) {
'pypi_upload': {cmd: process.env.PYTHON_PATH + '\\scripts\\twine upload dist/*'},
'pypi_cleanup': {cmd: process.env.PYTHON_PATH + '\\python setup.py clean'},
// Docker Commands
'build_docker_image': {
cmd: 'docker build --build-arg SOURCE_COMMIT=' + shell.exec("git rev-parse HEAD", {'silent': true}) + ' -t sickrage/sickrage:py3-alpha .'
},
'tag_docker_image': {
cmd: 'docker tag sickrage/sickrage:py3-alpha registry.sickrage.ca/sickrage/sickrage:py3-alpha'
},
'push_docker_image_to_docker_hub': {
cmd: [
'docker login -u ' + process.env.DOCKER_REGISTRY_USERNAME + ' -p ' + process.env.DOCKER_REGISTRY_PASSWORD,
'docker push sickrage/sickrage:py3-alpha',
].join('&&')
},
'push_docker_image_to_sickrage': {
cmd: [
'docker login -u ' + process.env.SICKRAGE_REGISTRY_USERNAME + ' -p ' + process.env.SICKRAGE_REGISTRY_PASSWORD,
'docker push registry.sickrage.ca/sickrage/sickrage:py3-alpha'
].join('&&')
},
// Git Commands
'git': {
cmd: function (cmd, branch) {
......@@ -199,6 +220,23 @@ module.exports = function (grunt) {
}
});
grunt.registerTask('release_docker_image', 'Build and Push Docker Image', function () {
grunt.log.writeln('Building and Pushing Docker Image...'.magenta);
const tasks = [
'exec:build_docker_image',
'exec:tag_docker_image',
'exec:push_docker_image_to_docker_hub',
'exec:push_docker_image_to_sickrage',
];
if (process.env.DOCKER_REGISTRY_USERNAME && process.env.DOCKER_REGISTRY_PASSWORD && process.env.SICKRAGE_REGISTRY_USERNAME && process.env.SICKRAGE_REGISTRY_PASSWORD) {
grunt.task.run(tasks);
} else {
grunt.log.warn('Missing login variables for docker registry, aborting task.'.bold);
}
});
grunt.registerTask('pre-release', function () {
grunt.task.run(['exec:git:checkout:develop']);
......
......@@ -66,6 +66,16 @@
</div>
</div>
<br/>
% elif os.environ.get('SOURCE_COMMIT'):
<div class="form-row">
<div class="col-lg-3 col-md-3 col-sm-3">
<i class="sickrage-core sickrage-core-commit"></i> ${_('SR Source Commit:')}
</div>
<div class="col-lg-9 col-md-9 col-sm-9">
${os.environ.get('SOURCE_COMMIT')}
</div>
</div>
<br/>
% endif
% if sr_user:
<div class="form-row">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment