diff --git a/.drone.yml b/.drone.yml index b15506e..db63423 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,14 +6,23 @@ name: build steps: - name: build-backend image: plugins/docker + environment: + TAG: + ${DRONE_TAG} + COMMIT: + ${DRONE_COMMIT} settings: insecure: true repo: 10.5.0.103:1222/simrail-backend registry: 10.5.0.103:1222 context: './packages/backend' dockerfile: './packages/backend/Dockerfile' + build_args_from_env: + - TAG + - COMMIT tags: - latest + - ${DRONE_TAG} - name: build-frontend image: plugins/docker @@ -33,7 +42,8 @@ steps: - VITE_STATS_KEY tags: - latest + - ${DRONE_TAG##v} trigger: - branch: - - main + event: + - tag \ No newline at end of file diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index d2b6668..ec3c96d 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -6,8 +6,12 @@ COPY . . RUN yarn add -D typescript RUN yarn rawbuild -RUN ls +ARG COMMIT +ENV COMMIT $COMMIT +ARG TAG +ENV TAG $TAG +RUN yarn make-git-info # Install Doppler CLI RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/cli@doppler-8004D9FF50437357.rsa.pub && \ @@ -17,4 +21,4 @@ RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.ke ENTRYPOINT ["doppler", "run", "--"] -CMD ["node", "/app/dist"] \ No newline at end of file +CMD ["node", "/app/dist/src"] \ No newline at end of file diff --git a/packages/backend/git.json b/packages/backend/git.json new file mode 100644 index 0000000..9a0294d --- /dev/null +++ b/packages/backend/git.json @@ -0,0 +1,4 @@ +{ + "tag": "", + "commit": "" +} \ No newline at end of file diff --git a/packages/backend/package.json b/packages/backend/package.json index 5bcad5e..d554ab5 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "docker build --progress=plain -t simrailpro:backend .", "rawbuild": "yarn tsc", - "start": "yarn rawbuild && node --env-file=.env dist/index.js" + "start": "yarn rawbuild && node --env-file=.env dist/index.js", + "make-git-info": "node scripts/make-git.js" }, "author": "Aleksander Wilczyński", "license": "AGPL-3.0-only", diff --git a/packages/backend/scripts/make-git.js b/packages/backend/scripts/make-git.js new file mode 100644 index 0000000..a15bc9a --- /dev/null +++ b/packages/backend/scripts/make-git.js @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2025 Aleksander Wilczyński (aleks@alekswilc.dev) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * See LICENSE for more. + */ + +import fs from 'node:fs/promises'; + +(async () => { + await fs.writeFile('dist/git.json', JSON.stringify({ + tag: process.env.TAG ?? "", + commit: process.env.COMMIT?.substring(0, 7) ?? "", + })) +})(); \ No newline at end of file diff --git a/packages/backend/src/util/git.ts b/packages/backend/src/util/git.ts index 07267d3..aa65e2e 100644 --- a/packages/backend/src/util/git.ts +++ b/packages/backend/src/util/git.ts @@ -14,7 +14,7 @@ * See LICENSE for more. */ -import { execSync } from "child_process"; +import gitInfo from '../../git.json' with { type: "json" }; export class GitUtil { @@ -22,28 +22,12 @@ export class GitUtil private static getLatestVersion() { - return process.env.CURRENT_VERSION; - // try - // { - // const data = execSync("git describe --tags --exact-match").toString(); - // return data.replace("\n", ""); - // } catch - // { - // return undefined; - // } + return gitInfo.tag; } private static getLatestCommit() { - return process.env.CURRENT_COMMIT; - // try - // { - // const data = execSync("git rev-parse --short HEAD").toString(); - // return data.replace("\n", ""); - // } catch - // { - // return undefined; - // } + return gitInfo.commit; } diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 92a305d..938225c 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -39,7 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ + "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/packages/frontend/src/components/pages/profiles/Profile.tsx b/packages/frontend/src/components/pages/profiles/Profile.tsx index ae80f81..ee5d0e7 100644 --- a/packages/frontend/src/components/pages/profiles/Profile.tsx +++ b/packages/frontend/src/components/pages/profiles/Profile.tsx @@ -169,7 +169,7 @@ export const ProfileCard = ({ data, images }: { data: TProfileData, images: TIma {dispatcherStats[dispatcherPage - 1].map(stationName => { const station = data.player.dispatcherStats[stationName]; - return + return })}
@@ -194,7 +194,7 @@ export const ProfileCard = ({ data, images }: { data: TProfileData, images: TIma
{trainStats[trainPage - 1].map(trainName => { const train = data.player.trainStats[trainName]; - return + return })}
diff --git a/packages/frontend/src/i18n/languages/cs.json b/packages/frontend/src/i18n/languages/cs.json index 645b941..e70a14f 100644 --- a/packages/frontend/src/i18n/languages/cs.json +++ b/packages/frontend/src/i18n/languages/cs.json @@ -20,7 +20,7 @@ "footer": { "license": "Licence:", "powered": "Založeno na:", - "thanks": "Speciální poděkování: BAHU.PRO hosting, Simrail ELITE discord, komunita SimRail a moje přítelkyně", + "thanks": "Speciální poděkování: BAHU.PRO hosting, Simrail ELITE discord, komunita SimRail", "author": "Pro komunitu SimRail vytvořeno s ❤️ uživatelem {{author}} " } }, diff --git a/packages/frontend/src/i18n/languages/en.json b/packages/frontend/src/i18n/languages/en.json index 9a80f12..61cc730 100644 --- a/packages/frontend/src/i18n/languages/en.json +++ b/packages/frontend/src/i18n/languages/en.json @@ -20,7 +20,7 @@ "footer": { "license": "License:", "powered": "Based on:", - "thanks": "Special thanks to BAHU.PRO hosting, Simrail ELITE discord, Simrail community and my girlfriend", + "thanks": "Special thanks to BAHU.PRO hosting, Simrail ELITE discord and Simrail community", "author": "Created by {{author}} with ❤️ for the Simrail community" } }, diff --git a/packages/frontend/src/i18n/languages/pl.json b/packages/frontend/src/i18n/languages/pl.json index 4f0eeb0..160a020 100644 --- a/packages/frontend/src/i18n/languages/pl.json +++ b/packages/frontend/src/i18n/languages/pl.json @@ -20,7 +20,7 @@ "footer": { "license": "Licencja:", "powered": "Oparte na:", - "thanks": "Specjalne podziękowania dla serwerowni BAHU.PRO, discorda Simrail ELITE, społeczności Simrail i mojej dziewczyny", + "thanks": "Specjalne podziękowania dla serwerowni BAHU.PRO, discorda Simrail ELITE i społeczności Simrail", "author": "Stworzone przez {{author}} z ❤️ dla społeczności Simrail" } },