From c082753cc6f99d6540c3befe02fff8e1c758dcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Choi=C5=84ski?= Date: Sun, 11 Feb 2024 00:06:28 +0100 Subject: [PATCH 1/2] ui: show app version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Grzegorz Choiński --- .github/workflows/deploy.yml | 2 +- Foodie/.dockerignore | 1 + Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css | 6 ++++++ Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html | 7 ++++++- Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts | 2 ++ Foodie/ClientApp/src/environments/environment.prod.ts | 5 ++++- Foodie/ClientApp/src/environments/environment.ts | 5 ++++- Foodie/ClientApp/src/environments/version.ts | 1 + Foodie/Dockerfile | 6 +++++- docker-compose.yml | 2 ++ 10 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 Foodie/ClientApp/src/environments/version.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d1a32ca..ea1df8d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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: | diff --git a/Foodie/.dockerignore b/Foodie/.dockerignore index c9ecbb4..75e54d7 100644 --- a/Foodie/.dockerignore +++ b/Foodie/.dockerignore @@ -1,4 +1,5 @@ bin/ obj/ .git +ClientApp/.angular/ ClientApp/node_modules/ diff --git a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css index 6df2fd5..d6a2c92 100644 --- a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css +++ b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css @@ -20,4 +20,10 @@ html { nav { background: linear-gradient(to right, #0cebeb, #20e3b2, #29ffc6); +} + +.version { + margin: 0; + font-size: x-small; + color: #fff; } \ No newline at end of file diff --git a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html index ea6aa3c..e1f6214 100644 --- a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html +++ b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.html @@ -1,7 +1,12 @@
diff --git a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts index 327a374..a92e3f4 100644 --- a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts +++ b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-nav-menu', @@ -7,6 +8,7 @@ import { Component } from '@angular/core'; }) export class NavMenuComponent { isExpanded = false; + version = environment.version; collapse() { this.isExpanded = false; diff --git a/Foodie/ClientApp/src/environments/environment.prod.ts b/Foodie/ClientApp/src/environments/environment.prod.ts index 3612073..2175d01 100644 --- a/Foodie/ClientApp/src/environments/environment.prod.ts +++ b/Foodie/ClientApp/src/environments/environment.prod.ts @@ -1,3 +1,6 @@ +import { version } from './version' + export const environment = { - production: true + production: true, + version: version, }; diff --git a/Foodie/ClientApp/src/environments/environment.ts b/Foodie/ClientApp/src/environments/environment.ts index 012182e..d86c737 100644 --- a/Foodie/ClientApp/src/environments/environment.ts +++ b/Foodie/ClientApp/src/environments/environment.ts @@ -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 }; /* diff --git a/Foodie/ClientApp/src/environments/version.ts b/Foodie/ClientApp/src/environments/version.ts new file mode 100644 index 0000000..f128572 --- /dev/null +++ b/Foodie/ClientApp/src/environments/version.ts @@ -0,0 +1 @@ +export const version = ''; diff --git a/Foodie/Dockerfile b/Foodie/Dockerfile index d9f8740..d891770 100644 --- a/Foodie/Dockerfile +++ b/Foodie/Dockerfile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 14432ec..1b01b96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: container_name: foodie build: context: ./Foodie + args: + APP_VERSION: "dev" depends_on: - db From 1b2bc55331d58dd7dd944dd1763c3092c1f1557d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Choi=C5=84ski?= Date: Sun, 11 Feb 2024 00:10:16 +0100 Subject: [PATCH 2/2] polish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Grzegorz Choiński --- Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css | 2 +- Foodie/ClientApp/src/environments/environment.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css index d6a2c92..32a4ad4 100644 --- a/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css +++ b/Foodie/ClientApp/src/app/nav-menu/nav-menu.component.css @@ -26,4 +26,4 @@ nav { margin: 0; font-size: x-small; color: #fff; -} \ No newline at end of file +} diff --git a/Foodie/ClientApp/src/environments/environment.ts b/Foodie/ClientApp/src/environments/environment.ts index d86c737..e3645b3 100644 --- a/Foodie/ClientApp/src/environments/environment.ts +++ b/Foodie/ClientApp/src/environments/environment.ts @@ -6,7 +6,7 @@ import { version } from './version' export const environment = { production: false, - version: version + version: version, }; /*