From b92c30835fda540cfd456523087e7b4c69456a4f Mon Sep 17 00:00:00 2001 From: Katarina Lejonlid Date: Wed, 23 Oct 2024 10:41:54 +0200 Subject: [PATCH 1/3] feat: adding information of current branch and commit hash --- docker-compose.yml | 1 + frontend/src/pages/Report.tsx | 4 ++ frontend/webpack.config.js | 76 +++++++++++++++++++---------------- node/Dockerfile | 9 +++++ 4 files changed, 56 insertions(+), 34 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 155b923a..c9a05b1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ services: volumes: - ./frontend:/home/node/app/ - exclude:/home/node/app/node_modules + - .git:/home/node/app/.git nginx: image: nginx:1.25.1-alpine diff --git a/frontend/src/pages/Report.tsx b/frontend/src/pages/Report.tsx index 229a7d00..e2b7e642 100644 --- a/frontend/src/pages/Report.tsx +++ b/frontend/src/pages/Report.tsx @@ -64,6 +64,8 @@ export const Report = () => { const [isLoading, setIsLoading] = useState(false); const context = React.useContext(AuthContext); const urlparams = useParams(); + const gitBranch = process.env.GIT_BRANCH; + const gitHash = process.env.GIT_HASH; // Effect only run on first render to check if the user has entered // a valid year and week in URL. @@ -830,6 +832,8 @@ export const Report = () => { +

Current Branch: {gitBranch}

+

Commit Hash: {gitHash}

diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index bb577725..d40d8196 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -1,71 +1,79 @@ -const path = require('path') -const webpack = require('webpack') -const HtmlWebpackPlugin = require('html-webpack-plugin') +const path = require("path"); +const webpack = require("webpack"); +const HtmlWebpackPlugin = require("html-webpack-plugin"); + +const { execSync } = require("child_process"); + +const gitBranch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim(); +const gitHash = execSync("git rev-parse --short HEAD").toString().trim(); module.exports = { - mode: 'development', + mode: "development", entry: { - index: './src/index.tsx' + index: "./src/index.tsx", }, module: { rules: [ { test: /\.(ts|tsx)$/i, - loader: 'ts-loader', - exclude: ['/node_modules/'], + loader: "ts-loader", + exclude: ["/node_modules/"], options: { - transpileOnly: true - } + transpileOnly: true, + }, }, { test: /\.(woff|woff2|png|svg|html)$/i, - type: 'asset' + type: "asset", }, { test: /\.(css)$/i, - use: ['style-loader', 'css-loader'] + use: ["style-loader", "css-loader"], }, { - test: /\.hbs$/, loader: 'handlebars-loader' - } - ] + test: /\.hbs$/, + loader: "handlebars-loader", + }, + ], }, resolve: { - extensions: ['.tsx', '.ts', '.jsx', '.js', '...'] + extensions: [".tsx", ".ts", ".jsx", ".js", "..."], }, - devtool: 'inline-source-map', + devtool: "inline-source-map", devServer: { open: true, - host: '0.0.0.0', + host: "0.0.0.0", port: 4242, compress: true, - allowedHosts: 'all', + allowedHosts: "all", historyApiFallback: true, - static: './public', + static: "./public", client: { - webSocketURL: 'ws://localhost:4567/ws', + webSocketURL: "ws://localhost:4567/ws", overlay: { errors: true, warnings: false, - runtimeErrors: false - } - } + runtimeErrors: false, + }, + }, }, plugins: [ new webpack.DefinePlugin({ - 'process.env.PUBLIC_API_URL': JSON.stringify(process.env.PUBLIC_API_URL), - 'process.env.PUBLIC_REDMINE_URL': JSON.stringify( + "process.env.PUBLIC_API_URL": JSON.stringify(process.env.PUBLIC_API_URL), + "process.env.PUBLIC_REDMINE_URL": JSON.stringify( process.env.PUBLIC_REDMINE_URL - ) + ), + "process.env.GIT_BRANCH": JSON.stringify(gitBranch), + "process.env.GIT_HASH": JSON.stringify(gitHash), }), new HtmlWebpackPlugin({ - filename: 'index.html', - publicPath: '/', - template: './src/template.hbs' - }) + filename: "index.html", + publicPath: "/", + template: "./src/template.hbs", + }), ], output: { - filename: './js/index.js', - path: path.resolve(__dirname, './public') - } -} + filename: "./js/index.js", + path: path.resolve(__dirname, "./public"), + }, +}; diff --git a/node/Dockerfile b/node/Dockerfile index 35914850..9a39132c 100644 --- a/node/Dockerfile +++ b/node/Dockerfile @@ -3,6 +3,15 @@ FROM node:20.3.0-alpine as build USER node RUN mkdir /home/node/app +# Switch to root user to install git +USER root + +# Install git with root privileges +RUN apk update && apk add --no-cache git + +# Switch back to the node user +USER node + WORKDIR /home/node COPY --chown=node:node /frontend/package.json /frontend/package-lock.json ./ RUN npm ci From 69114ba097a20734b2553d54b7c950613b560e92 Mon Sep 17 00:00:00 2001 From: Katarina Lejonlid Date: Wed, 23 Oct 2024 14:12:58 +0200 Subject: [PATCH 2/3] feat: styling the information as the rest of the app --- docker-compose.yml | 2 -- frontend/src/icons/info-circle-fill.svg | 3 +++ frontend/src/index.css | 4 ++++ frontend/src/pages/Report.tsx | 9 +++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 frontend/src/icons/info-circle-fill.svg diff --git a/docker-compose.yml b/docker-compose.yml index c9a05b1a..8faf9267 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ ---- -version: "3" services: diff --git a/frontend/src/icons/info-circle-fill.svg b/frontend/src/icons/info-circle-fill.svg new file mode 100644 index 00000000..8ff249d7 --- /dev/null +++ b/frontend/src/icons/info-circle-fill.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css index 2de534f1..0ad84111 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -470,6 +470,10 @@ Other button classes are defined further down together with other classes for th width: 1.7rem; } +.info-icon { + width: 1.3rem; +} + .hide-icon { width: 2rem; margin-top: 0.5rem; diff --git a/frontend/src/pages/Report.tsx b/frontend/src/pages/Report.tsx index e2b7e642..5558e8b1 100644 --- a/frontend/src/pages/Report.tsx +++ b/frontend/src/pages/Report.tsx @@ -37,6 +37,7 @@ import warning from "../icons/exclamation-triangle.svg"; import check from "../icons/check.svg"; import up from "../icons/caret-up-fill.svg"; import down from "../icons/caret-down-fill.svg"; +import info from "../icons/info-circle-fill.svg"; import { BarChart } from "../components/BarChart"; const beforeUnloadHandler = (event) => { @@ -832,10 +833,14 @@ export const Report = () => { -

Current Branch: {gitBranch}

-

Commit Hash: {gitHash}

+
+
+ {"information{" "} + Release from {gitBranch} ({gitHash}) +
+
From 3a7cb514363c0ef9c4dbf4b6bf3e5d449f06c676 Mon Sep 17 00:00:00 2001 From: Katarina Lejonlid Date: Tue, 26 Nov 2024 16:52:25 +0100 Subject: [PATCH 3/3] feat: adding changes to production folder and making adjustments of the front end --- frontend/public/index.html | 1 + production/Dockerfile.nginx | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 frontend/public/index.html diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100644 index 00000000..c97fc6bb --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1 @@ +Urdr timelogging
\ No newline at end of file diff --git a/production/Dockerfile.nginx b/production/Dockerfile.nginx index b3548503..a4a87111 100644 --- a/production/Dockerfile.nginx +++ b/production/Dockerfile.nginx @@ -1,9 +1,13 @@ FROM node:20.6.1-alpine as build +USER root +RUN apk update && apk add --no-cache git + USER node RUN mkdir /home/node/app WORKDIR /home/node COPY --chown=node:node ./package.json ./package-lock.json ./ +COPY --chown=node:node .git ./.git RUN npm ci FROM node:20.6.1-alpine as bundler