trying to fix docker build, so it includes git sha info.

pull/263/head
Jason Kulatunga 2 years ago
parent d7ddf01ea0
commit c7c55ab95c

@ -105,6 +105,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_VERSION=${{ github.ref_type == "tag" && github.ref_name || github.ref_name + "#" + github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
omnibus:
@ -151,5 +153,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_VERSION=${{ github.ref_type == "tag" && github.ref_name || github.ref_name + "#" + github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

@ -12,16 +12,14 @@ RUN go mod vendor && \
########
FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /opt/scrutiny/src
COPY . /opt/scrutiny/src
COPY webapp/frontend /opt/scrutiny/src
RUN apt-get update && apt-get install -y git && \
cd webapp/frontend && \
npm install -g @angular/cli@9.1.4 && \
RUN npm install -g @angular/cli@9.1.4 && \
mkdir -p /scrutiny/dist && \
npm install && \
npm run build:prod -- --output-path=/opt/scrutiny/dist

@ -10,16 +10,15 @@ RUN go mod vendor && \
########
FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
ENV
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /opt/scrutiny/src
COPY . /opt/scrutiny/src
COPY webapp/frontend /opt/scrutiny/src
RUN apt-get update && apt-get install -y git && \
cd webapp/frontend && \
npm install -g @angular/cli@9.1.4 && \
RUN npm install -g @angular/cli@9.1.4 && \
mkdir -p /opt/scrutiny/dist && \
npm install && \
npm run build:prod -- --output-path=/opt/scrutiny/dist

@ -5,18 +5,22 @@ import * as child from 'child_process';
const exec = promisify(child.exec);
async function createVersionsFile(filename: string) {
const tag = (await exec('git describe --tags')).stdout.toString().trim();
const revision = (await exec('git rev-parse --short HEAD')).stdout.toString().trim();
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
let versionInfo = ''
if(process.env.GIT_VERSION){
versionInfo = process.env.GIT_VERSION
} else {
const tag = (await exec('git describe --tags')).stdout.toString().trim();
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
versionInfo = (branch === 'master' ? tag : branch + '#' + tag)
}
console.log(`version: '${process.env.npm_package_version}', revision: '${revision}', branch: '${branch}'`);
const content = dedent`
// this file is automatically generated by git.version.ts script
export const versions = {
version: '${tag}',
revision: '${revision}',
branch: '${branch}'
export const versionInfo = {
version: '${versionInfo}',
};`;
writeFileSync(filename, content, {encoding: 'utf8'});

@ -4,7 +4,7 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { TreoMediaWatcherService } from '@treo/services/media-watcher';
import { TreoNavigationService } from '@treo/components/navigation';
import {versions} from 'environments/versions';
import {versionInfo} from 'environments/versions';
@Component({
selector : 'material-layout',
@ -49,7 +49,7 @@ export class MaterialLayoutComponent implements OnInit, OnDestroy
this.fixedHeader = false;
this.fixedFooter = false;
this.appVersion = `${versions.version}${versions.branch === 'master' ? '' : '#' + versions.branch}`
this.appVersion = versionInfo.version
}
// -----------------------------------------------------------------------------------------------------

@ -1,7 +1,5 @@
// this file is automatically generated by git.version.ts script
export const versions = {
export const versionInfo = {
version: 'v0.0.0',
revision: 'abcdef123',
branch: 'master'
};

Loading…
Cancel
Save