Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: show correct version on non-release builds
Kyle Mendelld0b6b354de71
diff --git a/backend/.air.toml b/backend/.air.tomlindex bea86ec95..7115d0253 100644--- a/backend/.air.toml+++ b/backend/.air.toml@@ -37,4 +37,4 @@ tmp_dir = ".bin"[screen]clear_on_rebuild = false- keep_scroll = true\ No newline at end of file+ keep_scroll = truediff --git a/backend/internal/api/version_handler.go b/backend/internal/api/version_handler.goindex 6b86ff1c2..85b1782ad 100644--- a/backend/internal/api/version_handler.go+++ b/backend/internal/api/version_handler.go@@ -16,6 +16,7 @@ type VersionHandler struct {func NewVersionHandler(api *gin.RouterGroup, version *services.VersionService) *VersionHandler {h := &VersionHandler{version: version}api.GET("/version", h.Get)+ api.GET("/app-version", h.GetAppVersion)return h}@@ -28,3 +29,8 @@ func (h *VersionHandler) Get(c *gin.Context) {}c.JSON(http.StatusOK, info)}++func (h *VersionHandler) GetAppVersion(c *gin.Context) {+ info := h.version.GetAppVersionInfo(c.Request.Context())+ c.JSON(http.StatusOK, info)+}diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.goindex 8c2a54523..cf975428b 100644--- a/backend/internal/bootstrap/services_bootstrap.go+++ b/backend/internal/bootstrap/services_bootstrap.go@@ -62,7 +62,7 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Configsvcs.Oidc = services.NewOidcService(svcs.Auth, cfg, httpClient)svcs.Updater = services.NewUpdaterService(db, svcs.Settings, svcs.Docker, svcs.Project, svcs.ImageUpdate, svcs.ContainerRegistry, svcs.Event, svcs.Image)svcs.System = services.NewSystemService(db, svcs.Docker, svcs.Container, svcs.Image, svcs.Volume, svcs.Network, svcs.Settings)- svcs.Version = services.NewVersionService(httpClient, cfg.UpdateCheckDisabled)+ svcs.Version = services.NewVersionService(httpClient, cfg.UpdateCheckDisabled, config.Version, config.Revision)return svcs, dockerClient, nil}diff --git a/backend/internal/dto/version_dto.go b/backend/internal/dto/version_dto.gonew file mode 100644index 000000000..8c00182c8--- /dev/null+++ b/backend/internal/dto/version_dto.go@@ -0,0 +1,11 @@+package dto++type VersionInfoDto struct {+ CurrentVersion string `json:"currentVersion"`+ Revision string `json:"revision"`+ DisplayVersion string `json:"displayVersion"`+ IsSemverVersion bool `json:"isSemverVersion"`+ NewestVersion string `json:"newestVersion,omitempty"`+ UpdateAvailable bool `json:"updateAvailable"`+ ReleaseURL string `json:"releaseUrl,omitempty"`+}diff --git a/backend/internal/services/version_service.go b/backend/internal/services/version_service.goindex 30507c765..07c331bc1 100644--- a/backend/internal/services/version_service.go+++ b/backend/internal/services/version_service.go@@ -10,6 +10,7 @@ import ("strings""time"+ "github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/utils/cache")@@ -23,9 +24,11 @@ type VersionService struct {httpClient *http.Clientcache *cache.Cache[string]disabled bool+ version string+ revision string}-func NewVersionService(httpClient *http.Client, disabled bool) *VersionService {+func NewVersionService(httpClient *http.Client, disabled bool, version string, revision string) *VersionService {if httpClient == nil {httpClient = http.DefaultClient}@@ -33,6 +36,8 @@ func NewVersionService(httpClient *http.Client, disabled bool) *VersionService {httpClient: httpClient,cache: cache.New[string](versionTTL),disabled: disabled,+ version: version,+ revision: revision,}}@@ -139,6 +144,86 @@ func (s *VersionService) GetVersionInformation(ctx context.Context, currentVersi}, nil}+// isSemverVersion checks if a version string is semver-based (e.g., v1.0.0)+func (s *VersionService) isSemverVersion() bool {+ version := strings.TrimPrefix(strings.TrimSpace(s.version), "v")+ parts := strings.Split(version, ".")+ if len(parts) < 3 {+ return false+ }+ for i := 0; i < 3; i++ {+ // Extract just the numeric part (ignoring suffixes like -alpha, +build)+ numPart := parts[i]+ if i == len(parts)-1 {+ // Last part might have additional info like "0-alpha" or "0+build"+ numPart = strings.FieldsFunc(numPart, func(r rune) bool {+ return r == '-' || r == '+'+ })[0]+ }+ if numPart == "" {+ return false+ }+ for _, c := range numPart {+ if c < '0' || c > '9' {+ return false+ }+ }+ }+ return true+}++// getDisplayVersion formats the version for display purposes+// If version contains "next", it returns "next-<revision>"+// Otherwise returns the version as-is+func (s *VersionService) getDisplayVersion() string {+ version := strings.TrimPrefix(strings.TrimSpace(s.version), "v")+ if strings.Contains(strings.ToLower(version), "next") && s.revision != "" && s.revision != "unknown" {+ return fmt.Sprintf("next-%s", s.revision)+ }+ return version+}++// GetAppVersionInfo returns application version information including display version+func (s *VersionService) GetAppVersionInfo(ctx context.Context) *dto.VersionInfoDto {+ version := strings.TrimPrefix(strings.TrimSpace(s.version), "v")+ displayVersion := s.getDisplayVersion()+ isSemver := s.isSemverVersion()++ if s.disabled {+ return &dto.VersionInfoDto{+ CurrentVersion: version,+ DisplayVersion: displayVersion,+ Revision: s.revision,+ IsSemverVersion: isSemver,+ UpdateAvailable: false,+ }+ }++ latest, err := s.GetLatestVersion(ctx)+ if err != nil {+ var staleErr *cache.ErrStale+ if !errors.As(err, &staleErr) {+ return &dto.VersionInfoDto{+ CurrentVersion: version,+ DisplayVersion: displayVersion,+ Revision: s.revision,+ IsSemverVersion: isSemver,+ }+ }+ slog.Warn("Failed to refresh latest version; using stale cache", "error", staleErr.Err)+ }++ return &dto.VersionInfoDto{+ CurrentVersion: version,+ DisplayVersion: displayVersion,+ Revision: s.revision,+ IsSemverVersion: isSemver,+ NewestVersion: latest,+ UpdateAvailable: s.IsNewer(latest, version) && isSemver,+ ReleaseURL: s.ReleaseURL(latest),+ }+}+func parseSemver(s string) [3]int {var out [3]intpart := 0diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.devindex ed4eb6f57..114242d19 100644--- a/docker/Dockerfile.dev+++ b/docker/Dockerfile.dev@@ -22,7 +22,7 @@ EXPOSE 3000# Start frontend development server with hot reloadCMD ["pnpm", "-C", "frontend", "dev", "--host", "0.0.0.0"]-# Stage 2: Backend Development+# Stage 2: Backend DevelopmentFROM golang:${GO_VERSION}-alpine AS backend-dev# Install development tools and dependenciesdiff --git a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelteindex 3f0e310d6..0f9d08104 100644--- a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte+++ b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte@@ -18,12 +18,12 @@updateAvailable?: boolean;} = $props();- console.log(versionInformation);-const sidebar = useSidebar();++ const shouldShowBanner = $derived(updateAvailable && versionInformation?.isSemverVersion);</script>-{#if updateAvailable}+{#if shouldShowBanner}<div class={cn('pb-2', isCollapsed ? 'px-1' : 'px-4')}><Separator.Root class="mb-3 opacity-30" />diff --git a/frontend/src/lib/components/sidebar/sidebar.svelte b/frontend/src/lib/components/sidebar/sidebar.svelteindex 010a07cfe..3f123651c 100644--- a/frontend/src/lib/components/sidebar/sidebar.svelte+++ b/frontend/src/lib/components/sidebar/sidebar.svelte@@ -54,7 +54,7 @@<div class="relative"><SidebarLogo {isCollapsed} {versionInformation} />{#if !isCollapsed}- <div class="absolute right-0 top-0 -mr-1 -mt-1">+ <div class="absolute top-0 right-0 -mt-1 -mr-1"><SidebarPinButton /></div>{/if}@@ -104,7 +104,9 @@{/if}<div class={`flex items-center justify-center ${isCollapsed ? 'px-1' : 'px-4'}`}><span class="text-muted-foreground/60 text-xs font-medium">- {m.sidebar_version({ version: versionInformation?.currentVersion ?? m.common_unknown() })}+ {m.sidebar_version({+ version: versionInformation?.displayVersion ?? versionInformation?.currentVersion ?? m.common_unknown()+ })}</span></div></Sidebar.Footer>diff --git a/frontend/src/lib/services/version-service.ts b/frontend/src/lib/services/version-service.tsindex 42c6803fa..1bc1b0a42 100644--- a/frontend/src/lib/services/version-service.ts+++ b/frontend/src/lib/services/version-service.ts@@ -7,27 +7,39 @@ function getCurrentVersion() {}async function getVersionInformation(): Promise<AppVersionInformation> {- const res = await axios.get('/api/version', {- params: { current: getCurrentVersion() },- timeout: 2000- });- const data = res.data as {- currentVersion?: string;- newestVersion?: string;- updateAvailable?: boolean;- releaseUrl?: string;- };+ try {+ const res = await axios.get('/api/app-version', {+ timeout: 2000+ });+ const data = res.data as {+ currentVersion?: string;+ displayVersion?: string;+ revision?: string;+ isSemverVersion?: boolean;+ newestVersion?: string;+ updateAvailable?: boolean;+ releaseUrl?: string;+ };- const current = getCurrentVersion();- const newest = data.newestVersion;- const updateAvailable = newest ? newest !== current : false;-- return {- currentVersion: current,- newestVersion: newest,- updateAvailable,- releaseUrl: data.releaseUrl- };+ return {+ currentVersion: data.currentVersion || getCurrentVersion(),+ displayVersion: data.displayVersion || data.currentVersion || getCurrentVersion(),+ revision: data.revision || 'unknown',+ isSemverVersion: data.isSemverVersion || false,+ newestVersion: data.newestVersion,+ updateAvailable: data.updateAvailable || false,+ releaseUrl: data.releaseUrl+ };+ } catch (error) {+ // Fallback to basic version info if app-version endpoint fails+ return {+ currentVersion: getCurrentVersion(),+ displayVersion: getCurrentVersion(),+ revision: 'unknown',+ isSemverVersion: false,+ updateAvailable: false+ };+ }}async function getNewestVersion(): Promise<string | undefined> {diff --git a/frontend/src/lib/types/application-configuration.ts b/frontend/src/lib/types/application-configuration.tsindex 314c31df6..7fe29e97f 100644--- a/frontend/src/lib/types/application-configuration.ts+++ b/frontend/src/lib/types/application-configuration.ts@@ -1,5 +1,8 @@export interface AppVersionInformation {currentVersion: string;+ displayVersion: string;+ revision: string;+ isSemverVersion: boolean;newestVersion?: string;updateAvailable?: boolean;releaseUrl?: string;diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.tsindex f7bc38bc7..fe12a785f 100644--- a/frontend/src/routes/+layout.ts+++ b/frontend/src/routes/+layout.ts@@ -40,15 +40,21 @@ export const load = async () => {});let versionInformation: AppVersionInformation = {- currentVersion: versionService.getCurrentVersion()+ currentVersion: versionService.getCurrentVersion(),+ displayVersion: versionService.getCurrentVersion(),+ revision: 'unknown',+ isSemverVersion: false};try {const info = await versionService.getVersionInformation();versionInformation = {currentVersion: info.currentVersion,+ displayVersion: info.displayVersion,+ revision: info.revision,+ isSemverVersion: info.isSemverVersion,newestVersion: info.newestVersion,- updateAvailable: info.newestVersion ? info.newestVersion !== info.currentVersion : false,+ updateAvailable: info.updateAvailable,releaseUrl: info.releaseUrl};} catch {}diff --git a/scripts/build-docker-next.sh b/scripts/build-docker-next.shnew file mode 100644index 000000000..cff1bd629--- /dev/null+++ b/scripts/build-docker-next.sh@@ -0,0 +1,31 @@+#!/usr/bin/env bash+set -euo pipefail++# Build script for "next" images on main branch+# Usage: ./scripts/build-docker-next.sh [TAG] [PULL]+# Example: ./scripts/build-docker-next.sh arcane:next --pull++# Get the current git revision (short commit hash)+REVISION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")++# For next builds, version is always "next"+VERSION="next"++# Parse optional arguments+TAG="${1:-arcane:next}"+PULL="${2:---pull}"++echo "Building Docker image: ${TAG}"+echo " VERSION: ${VERSION}"+echo " REVISION: ${REVISION}"+echo ""++docker build ${PULL} --rm \+ -f 'docker/Dockerfile' \+ --build-arg VERSION="${VERSION}" \+ --build-arg REVISION="${REVISION}" \+ -t "${TAG}" \+ .++echo ""+echo "✓ Build complete: ${TAG}"