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

This commit is contained in:
Jason Kulatunga
2022-05-26 23:44:13 -07:00
parent d7ddf01ea0
commit c7c55ab95c
6 changed files with 26 additions and 23 deletions
+4
View File
@@ -105,6 +105,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
omnibus: omnibus:
@@ -151,5 +153,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
+3 -5
View File
@@ -12,16 +12,14 @@ RUN go mod vendor && \
######## ########
FROM node:lts-slim as frontendbuild FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
#reduce logging, disable angular-cli analytics for ci environment #reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /opt/scrutiny/src WORKDIR /opt/scrutiny/src
COPY . /opt/scrutiny/src COPY webapp/frontend /opt/scrutiny/src
RUN apt-get update && apt-get install -y git && \ RUN npm install -g @angular/cli@9.1.4 && \
cd webapp/frontend && \
npm install -g @angular/cli@9.1.4 && \
mkdir -p /scrutiny/dist && \ mkdir -p /scrutiny/dist && \
npm install && \ npm install && \
npm run build:prod -- --output-path=/opt/scrutiny/dist npm run build:prod -- --output-path=/opt/scrutiny/dist
+4 -5
View File
@@ -10,16 +10,15 @@ RUN go mod vendor && \
######## ########
FROM node:lts-slim as frontendbuild FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
ENV
#reduce logging, disable angular-cli analytics for ci environment #reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /opt/scrutiny/src WORKDIR /opt/scrutiny/src
COPY . /opt/scrutiny/src COPY webapp/frontend /opt/scrutiny/src
RUN apt-get update && apt-get install -y git && \ RUN npm install -g @angular/cli@9.1.4 && \
cd webapp/frontend && \
npm install -g @angular/cli@9.1.4 && \
mkdir -p /opt/scrutiny/dist && \ mkdir -p /opt/scrutiny/dist && \
npm install && \ npm install && \
npm run build:prod -- --output-path=/opt/scrutiny/dist npm run build:prod -- --output-path=/opt/scrutiny/dist
+12 -8
View File
@@ -5,18 +5,22 @@ import * as child from 'child_process';
const exec = promisify(child.exec); const exec = promisify(child.exec);
async function createVersionsFile(filename: string) { async function createVersionsFile(filename: string) {
const tag = (await exec('git describe --tags')).stdout.toString().trim(); let versionInfo = ''
const revision = (await exec('git rev-parse --short HEAD')).stdout.toString().trim(); if(process.env.GIT_VERSION){
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim(); 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` const content = dedent`
// this file is automatically generated by git.version.ts script // this file is automatically generated by git.version.ts script
export const versions = { export const versionInfo = {
version: '${tag}', version: '${versionInfo}',
revision: '${revision}',
branch: '${branch}'
};`; };`;
writeFileSync(filename, content, {encoding: 'utf8'}); writeFileSync(filename, content, {encoding: 'utf8'});
@@ -4,7 +4,7 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { TreoMediaWatcherService } from '@treo/services/media-watcher'; import { TreoMediaWatcherService } from '@treo/services/media-watcher';
import { TreoNavigationService } from '@treo/components/navigation'; import { TreoNavigationService } from '@treo/components/navigation';
import {versions} from 'environments/versions'; import {versionInfo} from 'environments/versions';
@Component({ @Component({
selector : 'material-layout', selector : 'material-layout',
@@ -49,7 +49,7 @@ export class MaterialLayoutComponent implements OnInit, OnDestroy
this.fixedHeader = false; this.fixedHeader = false;
this.fixedFooter = false; this.fixedFooter = false;
this.appVersion = `${versions.version}${versions.branch === 'master' ? '' : '#' + versions.branch}` this.appVersion = versionInfo.version
} }
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
+1 -3
View File
@@ -1,7 +1,5 @@
// this file is automatically generated by git.version.ts script // this file is automatically generated by git.version.ts script
export const versions = { export const versionInfo = {
version: 'v0.0.0', version: 'v0.0.0',
revision: 'abcdef123',
branch: 'master'
}; };