Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: show app version #55

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v3

- name: Build the Docker image
run: docker build ./Foodie --tag $IMAGE_NAME:$TAG
run: docker build ./Foodie --build-arg APP_VERSION=$TAG --tag $IMAGE_NAME:$TAG

- name: Publish image
run: |
Expand Down
1 change: 1 addition & 0 deletions Foodie/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/
obj/
.git
ClientApp/.angular/
ClientApp/node_modules/
8 changes: 7 additions & 1 deletion Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ html {

nav {
background: linear-gradient(to right, #0cebeb, #20e3b2, #29ffc6);
}
}

.version {
margin: 0;
font-size: x-small;
color: #fff;
}
7 changes: 6 additions & 1 deletion Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" [routerLink]="['/']">Foodie</a>
<div>
<a class="navbar-brand" [routerLink]="['/']">
Foodie
<span class="version" *ngIf="version">&nbsp;|&nbsp;{{version}}</span>
</a>
</div>
<app-login-menu></app-login-menu>
</div>
</nav>
Expand Down
2 changes: 2 additions & 0 deletions Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { environment } from 'src/environments/environment';

@Component({
selector: 'app-nav-menu',
Expand All @@ -7,6 +8,7 @@ import { Component } from '@angular/core';
})
export class NavMenuComponent {
isExpanded = false;
version = environment.version;

collapse() {
this.isExpanded = false;
Expand Down
5 changes: 4 additions & 1 deletion Foodie/ClientApp/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { version } from './version'

export const environment = {
production: true
production: true,
version: version,
};
5 changes: 4 additions & 1 deletion Foodie/ClientApp/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

import { version } from './version'

export const environment = {
production: false
production: false,
version: version,
};

/*
Expand Down
1 change: 1 addition & 0 deletions Foodie/ClientApp/src/environments/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const version = '';
6 changes: 5 additions & 1 deletion Foodie/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_18.x | bash \
&& apt-get install nodejs -yq

ARG APP_VERSION

WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN echo "export const version = '${APP_VERSION}';" > ClientApp/src/environments/version.ts
RUN dotnet publish -c Release -o out

# Build runtime image
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
container_name: foodie
build:
context: ./Foodie
args:
APP_VERSION: "dev"
depends_on:
- db

Expand Down
Loading