Skip to content

Commit a7fa3d5

Browse files
committed
ARTESCA-14679 // add version in remoteEntry file
Add step to retrieve METALK8S_VERSION in build workflow Remove METALK8S_VERSION retrieval step and add version fallback in doit.sh Refactor version retrieval logic in doit.sh and entrypoint.sh to improve clarity and maintainability Update VERSION_FILE path in entrypoint.sh for consistency Update Dockerfile to include VERSION file and remove version retrieval logic from entrypoint.sh Update Dockerfile and rspack.config.ts to remove VERSION file dependency and use git revision for filename Update Dockerfile to copy VERSION file and modify rspack.config.ts to read version from the file Update Dockerfile to create VERSION file with version details during build
1 parent ee5f03e commit a7fa3d5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ui/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ WORKDIR /home/node
99
COPY package.json package-lock.json tsconfig.json /home/node/
1010
RUN npm ci --legacy-peer-deps
1111

12+
USER root
13+
RUN mkdir -p /home && echo -e "VERSION_MAJOR=1\nVERSION_MINOR=0\nVERSION_PATCH=0\nVERSION_SUFFIX=" > /home/VERSION
14+
USER node
15+
1216
COPY entrypoint.sh /entrypoint.sh
1317

1418
ENTRYPOINT ["/entrypoint.sh"]

ui/rspack.config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@ import packageJson from './package.json';
33
import { Configuration } from '@rspack/cli';
44
import rspack from '@rspack/core';
55
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
6+
import fs from 'fs';
67

78
const deps = packageJson.dependencies;
89

910
const isProduction = process.env.NODE_ENV === 'production';
1011

12+
let version = process.env.VERSION;
13+
if (!version) {
14+
const versionFileContents = fs.readFileSync(
15+
path.join(__dirname, '../VERSION'),
16+
{ encoding: 'utf-8' },
17+
);
18+
const versionRegex =
19+
/.*VERSION_MAJOR=(?<versionMajor>\d+)(\n){0,1}.*VERSION_MINOR=(?<versionMinor>\d+)(\n){0,1}.*VERSION_PATCH=(?<versionPatch>\d+)(\n){0,1}.*VERSION_SUFFIX=(?<versionSuffix>.*)/m;
20+
const { versionMajor, versionMinor, versionPatch, versionSuffix } =
21+
versionRegex.exec(versionFileContents).groups;
22+
version = `${versionMajor}.${versionMinor}.${versionPatch}${versionSuffix}`;
23+
}
24+
1125
const config: Configuration = {
1226
entry: {
1327
metalk8s_ui: './src/index.ts',
@@ -97,7 +111,7 @@ const config: Configuration = {
97111
plugins: [
98112
new ModuleFederationPlugin({
99113
name: 'metalk8s',
100-
filename: 'static/js/remoteEntry.js',
114+
filename: `static/js/remoteEntry.${version}.js`,
101115
exposes: {
102116
'./FederableApp': './src/FederableApp.tsx',
103117
'./platformLibrary': './src/services/platformlibrary/k8s.ts',

0 commit comments

Comments
 (0)