Skip to content

Commit caf7e20

Browse files
FEATURE (versions): Add version display to Postgresus
1 parent 6a71dd4 commit caf7e20

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

.github/workflows/ci-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ jobs:
301301
context: .
302302
push: true
303303
platforms: linux/amd64,linux/arm64
304+
build-args: |
305+
APP_VERSION=dev-${{ github.sha }}
304306
tags: |
305307
rostislavdugin/postgresus:latest
306308
rostislavdugin/postgresus:${{ github.sha }}
@@ -333,6 +335,8 @@ jobs:
333335
context: .
334336
push: true
335337
platforms: linux/amd64,linux/arm64
338+
build-args: |
339+
APP_VERSION=${{ needs.determine-version.outputs.new_version }}
336340
tags: |
337341
rostislavdugin/postgresus:latest
338342
rostislavdugin/postgresus:v${{ needs.determine-version.outputs.new_version }}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ FROM --platform=$BUILDPLATFORM node:24-alpine AS frontend-build
33

44
WORKDIR /frontend
55

6+
# Add version for the frontend build
7+
ARG APP_VERSION=dev
8+
ENV VITE_APP_VERSION=$APP_VERSION
9+
610
COPY frontend/package.json frontend/package-lock.json ./
711
RUN npm ci
812
COPY frontend/ ./
@@ -53,6 +57,11 @@ RUN CGO_ENABLED=0 \
5357
# ========= RUNTIME =========
5458
FROM --platform=$TARGETPLATFORM debian:bookworm-slim
5559

60+
# Add version metadata to runtime image
61+
ARG APP_VERSION=dev
62+
LABEL org.opencontainers.image.version=$APP_VERSION
63+
ENV APP_VERSION=$APP_VERSION
64+
5665
# Install PostgreSQL server and client tools (versions 13-17)
5766
RUN apt-get update && apt-get install -y --no-install-recommends \
5867
wget ca-certificates gnupg lsb-release sudo gosu && \

backend/cmd/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ func main() {
5151
runMigrations(log)
5252

5353
// create directories that used for backups and restore
54-
files_utils.EnsureDirectories([]string{
54+
err := files_utils.EnsureDirectories([]string{
5555
config.GetEnv().TempFolder,
5656
config.GetEnv().DataFolder,
5757
})
5858

59+
if err != nil {
60+
log.Error("Failed to ensure directories", "error", err)
61+
os.Exit(1)
62+
}
63+
5964
// Handle password reset if flag is provided
6065
newPassword := flag.String("new-password", "", "Set a new password for the user")
6166
flag.Parse()

frontend/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ export function getApplicationServer() {
1212
}
1313

1414
export const GOOGLE_DRIVE_OAUTH_REDIRECT_URL = 'https://postgresus.com/storages/google-oauth';
15+
16+
export const APP_VERSION = (import.meta.env.VITE_APP_VERSION as string) || 'dev';

frontend/src/widgets/main/MainScreenComponent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Tooltip } from 'antd';
22
import { useEffect, useState } from 'react';
33
import GitHubButton from 'react-github-btn';
44

5-
import { getApplicationServer } from '../../constants';
5+
import { APP_VERSION, getApplicationServer } from '../../constants';
66
import { type DiskUsage, diskApi } from '../../entity/disk';
77
import { DatabasesComponent } from '../../features/databases/ui/DatabasesComponent';
88
import { NotifiersComponent } from '../../features/notifiers/ui/NotifiersComponent';
@@ -101,7 +101,7 @@ export const MainScreenComponent = () => {
101101
</div>
102102
{/* ===================== END NAVBAR ===================== */}
103103

104-
<div className="flex">
104+
<div className="relative flex">
105105
<div
106106
className="max-w-[60px] min-w-[60px] rounded bg-white py-2 shadow"
107107
style={{ height: contentHeight }}
@@ -152,6 +152,10 @@ export const MainScreenComponent = () => {
152152
{selectedTab === 'notifiers' && <NotifiersComponent contentHeight={contentHeight} />}
153153
{selectedTab === 'storages' && <StoragesComponent contentHeight={contentHeight} />}
154154
{selectedTab === 'databases' && <DatabasesComponent contentHeight={contentHeight} />}
155+
156+
<div className="absolute bottom-1 left-1 mb-[0px] text-sm text-gray-400">
157+
v{APP_VERSION}
158+
</div>
155159
</div>
156160
</div>
157161
);

0 commit comments

Comments
 (0)