Skip to content

Commit

Permalink
Expose version and git hash
Browse files Browse the repository at this point in the history
Display the git commit hash and version in the footer.
Additionally modify the Dockerfile to expose
thse information as ARGs and ENVs.
Remove the Google API key from the code and pass it in as a parameter.
  • Loading branch information
timeu committed Jun 17, 2020
1 parent 67d41a2 commit bc026ff
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 10 deletions.
25 changes: 19 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM maven:3.3.3-jdk-8 as maven_builder
ARG GIT_BRANCH
ARG GIT_COMMIT
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
ARG BUILD_NUMBER
ARG BUILD_URL

FROM maven:3.3.3-jdk-8 as maven_builder
RUN mkdir -p /code/src

WORKDIR /code/src

COPY src/pom.xml .
COPY src/genophenbrowser-server/pom.xml genophenbrowser-server/
COPY src/genophenbrowser-shared/pom.xml genophenbrowser-shared/
COPY src/genophenbrowser-client/pom.xml genophenbrowser-client/
RUN ["mvn","de.qaware.maven:go-offline-maven-plugin:resolve-dependencies","verify", "clean","-B", "--fail-never"]

COPY src /code/src

RUN ["mvn", "clean", "package"]

RUN mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[' | tail -n 1 > version
RUN export VERSION=$(cat version); cp genophenbrowser-server/target/genophenbrowser-server-${VERSION}.war /root/ROOT.war

Expand Down Expand Up @@ -42,3 +43,15 @@ USER gwaportal
RUN cp $JETTY_HOME/lib/jetty-proxy*jar $JETTY_BASE/lib/ext
RUN java -jar "$JETTY_HOME/start.jar" --add-to-startd=servlets
COPY --chown=gwaportal:gwaportal bioportal-ontology-detail.cache ProgramData/cache/bioportal-ontology-detail.cache
ARG GIT_BRANCH
ARG GIT_COMMIT
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
ARG BUILD_NUMBER
ARG BUILD_URL
ENV VERSION ${GIT_BRANCH:-$SOURCE_BRANCH}
ENV COMMIT_HASH ${GIT_COMMIT:-$SOURCE_COMMIT}
ENV BUILD_NUMBER $BUILD_NUMBER
ENV BUILD_URL $BUILD_URL
RUN echo ${VERSION}

3 changes: 1 addition & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
def jobsMapping = [
tags: [jobName:"App GWAPortal", jobTags: "reload", extraVars: "app_generic_image_tag: latest"],
master: [jobName:"App GWAPortal", jobTags: "reload", extraVars: "app_generic_image_tag: master"]
tags: [jobName:"App GWAPortal", jobTags: "reload", extraVars: "app_generic_image_tag: latest"]
]

buildDockerImage([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected void handleSuccess() {
};
/* FIXME https://code.google.com/p/gwt-charts/issues/detail?id=53 */
ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART, ChartPackage.ORGCHART, ChartPackage.GEOCHART, ChartPackage.MOTIONCHART);
chartLoader.setMapsApiKey("AIzaSyADR9bZKW2zh8GcDHRVWZOdZafVg6U86Hg");
chartLoader.setMapsApiKey(getMapsApiKey());
// FIXME Required because newer version will cause a JSON parse errro. This needs to be investigated on the backend
chartLoader.setVersion("45.2");
chartLoader.loadApi(chartsRunnable);
Expand Down Expand Up @@ -166,6 +166,21 @@ public static String getContactEmail() {
return data.get("contactEmail");
}

public static String getVersion() {
Dictionary data = Dictionary.getDictionary("appData");
return data.get("version");
}

public static String getCommitHash() {
Dictionary data = Dictionary.getDictionary("appData");
return data.get("commitHash");
}

public static String getMapsApiKey() {
Dictionary data = Dictionary.getDictionary("appData");
return data.get("mapsApiKey");
}

public static LinkedHashSet<String> getChromosomes() {
Dictionary data = Dictionary.getDictionary("appData");
return Sets.newLinkedHashSet(Splitter.on(",").split(data.get("chromosomes")));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmi.nordborglab.browser.client.mvp;

import com.gmi.nordborglab.browser.client.bootstrap.BootstrapperImpl;
import com.gmi.nordborglab.browser.client.mvp.ApplicationPresenter.MENU;
import com.gmi.nordborglab.browser.client.resources.MainResources;
import com.gmi.nordborglab.browser.client.security.CurrentUser;
Expand All @@ -9,6 +10,7 @@
import com.gmi.nordborglab.browser.client.util.DateUtils;
import com.gmi.nordborglab.browser.shared.proxy.AppUserProxy;
import com.gmi.nordborglab.browser.shared.proxy.UserNotificationProxy;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.ImageElement;
Expand All @@ -31,6 +33,7 @@
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimpleLayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.safehtml.shared.UriUtils;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
Expand Down Expand Up @@ -88,6 +91,8 @@ interface MyStyle extends CssResource {
SpanElement arrorIcon;
@UiField
SpanElement notifyBubble;
@UiField
AnchorElement versionLink;

private final Favico favIco;

Expand Down Expand Up @@ -150,6 +155,15 @@ public void f(Element e) {
notificationbar.stop().fadeTo(500, 0);
}
});
String version = BootstrapperImpl.getVersion();
String commitHash = BootstrapperImpl.getCommitHash();
if (commitHash != "") {
versionLink.setHref(UriUtils.fromString("https://github.com/Gregor-Mendel-Institute/GWA-Portal/commit/" + commitHash).asString());
if (version == "") {
version = commitHash.substring(0, Math.min(7, commitHash.length()));
}
versionLink.setInnerText(version);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
height: 3.423em;
}

.footer_version {
float: right;
vertical-align: middle;
padding-top: 20px;
font-size: 13px;
color: #999;
}

.footer_items {
float: left;
line-height: 3.423em;
Expand Down Expand Up @@ -386,6 +394,8 @@
</g:center>
<g:south size="4.423">
<g:HTMLPanel addStyleNames="{style.footer}" ui:field="footerPanel">
<div class="{style.footer_version}">Version: <a target="_blank" ui:field="versionLink">N/A</a>
</div>
<div ui:field="footerContentPanel">
<div class="{style.footer_content}">
<div class="{style.footer_items}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ GENOME.chrlengths=30429953,19701870,23467451,18578708,26992130
GENOME.chromosomes=1,2,3,4,5
GA.trackingid={GA.TRACKERID}
SITE.contactemail=[email protected]
SITE.mapsApiKey={API KEY for MAPS}
HDF5_SERVER={HDF5_SERVER}
GENE.info_url=https://apps.araport.org/thalemine/portal.do?externalids={0}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ public class MainController {
@Value("${GENOME.chromosomes}")
private String chromosomes = "";

@Value("#{environment.VERSION}")
private String version;

@Value("#{environment.COMMIT_HASH}")
private String commitHash;

@Value("${SITE.mapsApiKey}")
private String mapsApiKey;

@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})
public ModelAndView index() {

Expand All @@ -35,6 +44,10 @@ public ModelAndView index() {
result.addObject("contactEmail", contactEmail);
result.addObject("geneInfoUrl",geneInfoUrl);
result.addObject("chromosomes", chromosomes);
result.addObject("version", version);
result.addObject("commitHash", commitHash);
result.addObject("mapsApiKey", mapsApiKey);

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@
'geneInfoUrl': '${geneInfoUrl}',
'gaTrackingId': '${gaTrackingId}',
'contactEmail': '${contactEmail}',
'chromosomes': '${chromosomes}'
'chromosomes': '${chromosomes}',
'version': '${version}',
'commitHash': '${commitHash}',
'mapsApiKey': '${mapsApiKey}',
};
<%@ include file="/browser/browser.nocache.js" %>
</script>
Expand Down

0 comments on commit bc026ff

Please sign in to comment.