Added version information to bottom of screen

At the bottom of the screen the docker-registry-frontend will now render the
commit upon the running version is built. The commit is linked to the github
commit page.
This commit is contained in:
Konrad Kleine 2014-10-23 09:41:44 +02:00
parent 6c05b4ff7f
commit 0861441c37
7 changed files with 36 additions and 6 deletions

View file

@ -1,4 +1,3 @@
.git
node_modules
dist
.tmp

View file

@ -12,6 +12,8 @@ ENV WWW_DIR /var/www/html
ENV SOURCE_DIR /tmp/source
ENV START_SCRIPT /root/start-apache.sh
RUN mkdir -pv $WWW_DIR
############################################################
# Speedup DPKG and don't use cache for packages
############################################################
@ -68,6 +70,17 @@ ADD LICENSE $SOURCE_DIR/
ADD package.json $SOURCE_DIR/
ADD README.md $SOURCE_DIR/
# Add Git version information to it's own json file app-version.json
RUN mkdir -p $SOURCE_DIR/.git
ADD .git/HEAD $SOURCE_DIR/.git/HEAD
ADD .git/refs $SOURCE_DIR/.git/refs
RUN cd $SOURCE_DIR && \
export GITREF=$(cat .git/HEAD | cut -d" " -f2) && \
export GITSHA1=$(cat .git/$GITREF) && \
echo "{\"git\": {\"sha1\": \"$GITSHA1\", \"ref\": \"$GITREF\"}}" > $WWW_DIR/app-version.json && \
cd $SOURCE_DIR && \
rm -rf $SOURCE_DIR/.git
############################################################
# This is written so compact, to reduce the size of the
# final container and its layers. We have to install build
@ -78,7 +91,6 @@ ADD README.md $SOURCE_DIR/
# installed app artifacts.
############################################################
RUN mkdir -pv $WWW_DIR
RUN apt-get -y install \
git \
nodejs \

1
app/app-version.json Normal file
View file

@ -0,0 +1 @@
{"git": {"sha1": "foo", "ref": "bar"}}

View file

@ -1,6 +1,6 @@
<!doctype html>
<html class="no-js" ng-app="docker-registry-frontend">
<head ng-controller="MainController as main">
<html class="no-js" ng-app="docker-registry-frontend" ng-controller="MainController as main">
<head>
<meta charset="utf-8">
<title ng-bind-template="Docker registry {{main.$location.path()}}">Docker registry</title>
<meta name="description" content="">
@ -37,6 +37,7 @@
<p class="text-muted"><a href="#/about">About the Docker Registry Frontend</a></p>
<p><span class="glyphicon glyphicon-fire"></span> <a href="https://github.com/kwk/docker-registry-frontend/issues/new">Report a bug</a></p>
<p><span class="glyphicon glyphicon-random"></span> <a href="https://github.com/kwk/docker-registry-frontend">Fork me on GitHub</a></p>
<p class="text-muted"><small>This is git revision: <a href="https://github.com/kwk/docker-registry-frontend/commit/{{appVersion.git.sha1}}"><span ng-bind-template="{{appVersion.git.sha1 | limitTo: 7}}">-</span></a></small></p>
</div>
</div>
@ -82,6 +83,7 @@
<script src="scripts/directives/tag-list-directive.js"></script>
<script src="scripts/directives/image-details-directive.js"></script>
<script src="scripts/services/registry-services.js"></script>
<script src="scripts/services/app-version-services.js"></script>
<!-- endbuild -->
</body>
</html>

View file

@ -32,6 +32,7 @@ angular
'ui.bootstrap',
'angular-loading-bar',
'angularMoment',
'app-version-services',
])
.config(['$routeProvider', '$resourceProvider', 'cfpLoadingBarProvider', function($routeProvider, $resourceProvider, cfpLoadingBarProvider){

View file

@ -8,9 +8,10 @@
* Controller of the docker-registry-frontend
*/
angular.module('main-controller', [])
.controller('MainController', ['$scope', '$route', '$routeParams', '$location',
function($scope, $route, $routeParams, $location){
.controller('MainController', ['$scope', '$route', '$routeParams', '$location', 'AppVersion',
function($scope, $route, $routeParams, $location, AppVersion){
this.$route = $route;
this.$location = $location;
this.$routeParams = $routeParams;
$scope.appVersion = AppVersion.query();
}]);

View file

@ -0,0 +1,14 @@
'use strict';
// This allows the application to query information about its version.
// The "app-version.json" file will be build during "docker build".
angular.module('app-version-services', ['ngResource'])
.factory('AppVersion', ['$resource', '$log', function($resource, $log){
return $resource('/app-version.json', {}, {
'query': {
method:'GET',
isArray: false,
},
});
}]);