Skip to content

Modern Docker Management, Designed for Everyone

refactor: use distroless images over DHI to support all platforms

Kyle Mendell86b7f60f63ae
diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.go
index f34974526..d4daf87dd 100644
--- a/backend/internal/bootstrap/bootstrap.go
+++ b/backend/internal/bootstrap/bootstrap.go
@@ -45,7 +45,8 @@ func Bootstrap(ctx context.Context) error {
SetupSlogLogger(cfg)
ConfigureGormLogger(cfg)
- slog.InfoContext(ctx, "Arcane is starting", "version", config.Version)
+ slog.InfoContext(ctx, "Arcane is starting...", "version", config.Version)
+ slog.InfoContext(ctx, "Arcane Identity Configuration", "PUID", os.Getuid(), "PGID", os.Getgid())
appCtx, cancelApp := context.WithCancel(ctx)
defer cancelApp()
@@ -108,9 +109,7 @@ func newConfiguredHTTPClient(cfg *config.Config) *http.Client {
func initializeStartupState(appCtx context.Context, cfg *config.Config, appServices *Services, dockerClientService *services.DockerClientService, httpClient *http.Client) {
if appServices.Volume != nil {
- if err := appServices.Volume.CleanupOrphanedVolumeHelpers(appCtx); err != nil {
- slog.WarnContext(appCtx, "Failed to cleanup orphaned volume helpers on startup", "error", err)
- }
+ startup.CleanupOrphanedVolumeHelpers(appCtx, appServices.Volume.CleanupOrphanedVolumeHelpers)
}
runtimeCfg := &startup.RuntimeConfig{
diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.go
index c085928f0..20d49ead0 100644
--- a/backend/internal/services/settings_service.go
+++ b/backend/internal/services/settings_service.go
@@ -56,7 +56,7 @@ func NewSettingsService(ctx context.Context, db *database.DB) (*SettingsService,
}
svc.envOverrides = resolveSettingsEnvOverridesInternal()
if len(svc.envOverrides) > 0 {
- slog.InfoContext(ctx, "settings env overrides loaded", "count", len(svc.envOverrides))
+ slog.InfoContext(ctx, "Loaded Environment Settings Overrides", "count", len(svc.envOverrides))
}
err := svc.LoadDatabaseSettings(ctx)
diff --git a/backend/internal/services/volume_service.go b/backend/internal/services/volume_service.go
index 77be9ccf4..cde586678 100644
--- a/backend/internal/services/volume_service.go
+++ b/backend/internal/services/volume_service.go
@@ -953,15 +953,17 @@ func (s *VolumeService) takeHelperIDInternal(volumeName string) string {
return helper.id
}
-func (s *VolumeService) CleanupOrphanedVolumeHelpers(ctx context.Context) error {
+func (s *VolumeService) CleanupOrphanedVolumeHelpers(ctx context.Context) (int, error) {
+ slog.DebugContext(ctx, "volume service: cleanup orphaned volume helper containers")
+
dockerClient, err := s.dockerService.GetClient(ctx)
if err != nil {
- return fmt.Errorf("failed to get docker client for orphan helper cleanup: %w", err)
+ return 0, fmt.Errorf("failed to get docker client for orphan helper cleanup: %w", err)
}
containers, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{All: true})
if err != nil {
- return fmt.Errorf("failed to list containers for orphan helper cleanup: %w", err)
+ return 0, fmt.Errorf("failed to list containers for orphan helper cleanup: %w", err)
}
removedCount := 0
@@ -971,15 +973,19 @@ func (s *VolumeService) CleanupOrphanedVolumeHelpers(ctx context.Context) error
}
if _, err := dockerClient.ContainerRemove(ctx, c.ID, volumeHelperRemoveOptionsInternal()); err != nil {
- slog.WarnContext(ctx, "failed to remove orphaned volume helper container", "container_id", c.ID, "error", err.Error())
+ slog.WarnContext(ctx,
+ "volume service: failed to remove orphaned volume helper container",
+ "container_id", c.ID,
+ "container_names", c.Names,
+ "error", err.Error(),
+ )
continue
}
removedCount++
}
- slog.InfoContext(ctx, "volume service: orphan helper cleanup completed", "removed_count", removedCount)
- return nil
+ return removedCount, nil
}
func (s *VolumeService) removeHelperEntry(volumeName string) {
diff --git a/backend/pkg/libarcane/startup/startup.go b/backend/pkg/libarcane/startup/startup.go
index f909e330f..29c8be8f5 100644
--- a/backend/pkg/libarcane/startup/startup.go
+++ b/backend/pkg/libarcane/startup/startup.go
@@ -74,6 +74,22 @@ func TestDockerConnection(ctx context.Context, testFunc func(context.Context) er
}
}
+func CleanupOrphanedVolumeHelpers(ctx context.Context, cleanupFunc func(context.Context) (int, error)) {
+ if cleanupFunc == nil {
+ return
+ }
+
+ slog.InfoContext(ctx, "Checking for orphaned volume helper containers from previous runs")
+
+ removedCount, err := cleanupFunc(ctx)
+ if err != nil {
+ slog.WarnContext(ctx, "Failed to clean up orphaned volume helper containers during startup", "error", err.Error())
+ return
+ }
+
+ slog.InfoContext(ctx, "Orphaned volume helper cleanup completed", "removed_count", removedCount)
+}
+
func InitializeNonAgentFeatures(
ctx context.Context,
cfg *RuntimeConfig,
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 388dc8fea..2e7967a28 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG BUILD_TAGS=""
-ARG ARCANE_RUNTIME_BASE_IMAGE=ghcr.io/getarcaneapp/base:trixie
+ARG ARCANE_RUNTIME_BASE_IMAGE=ghcr.io/getarcaneapp/base:distroless
# Stage 1: Build Frontend
FROM --platform=$BUILDPLATFORM node:25-trixie-slim AS frontend-builder
@@ -65,6 +65,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o /build/arcane \
./cmd/main.go
+RUN mkdir -p /build/rootfs/app/data /build/rootfs/builds
+
# Stage 3: Hardened Production Image
FROM ${ARCANE_RUNTIME_BASE_IMAGE} AS runner-hardened
@@ -85,10 +87,11 @@ ENV NVIDIA_VISIBLE_DEVICES=all \
WORKDIR /app
+# The container starts as "root", but arcane drops to the requetsed PUID and PGID after the runtime is initialized
USER 0:0
-RUN mkdir -p /app/data /builds \
- && chown -R 65532:65532 /app /builds
-COPY --from=backend-builder /build/arcane .
+COPY --from=backend-builder --chown=65532:65532 /build/rootfs/app/ /app/
+COPY --from=backend-builder --chown=65532:65532 /build/rootfs/builds/ /builds/
+COPY --from=backend-builder --chown=65532:65532 /build/arcane .
EXPOSE 3552
VOLUME ["/app/data"]
diff --git a/docker/Dockerfile-agent b/docker/Dockerfile-agent
index 7e3422b65..fa70776cb 100644
--- a/docker/Dockerfile-agent
+++ b/docker/Dockerfile-agent
@@ -44,15 +44,15 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o /out/arcane-agent \
./cmd/main.go
+RUN mkdir -p /out/rootfs/app/data
+
FROM ${ARCANE_RUNTIME_BASE_IMAGE} AS agent
ARG TARGETARCH
WORKDIR /app
-USER 0:0
-RUN mkdir -p /app/data \
- && chown -R 65532:65532 /app
-COPY --from=agent-builder /out/arcane-agent ./arcane-agent
+COPY --from=agent-builder --chown=65532:65532 /out/rootfs/app/ /app/
+COPY --from=agent-builder --chown=65532:65532 /out/arcane-agent ./arcane-agent
ARG VERSION="dev"
ARG REVISION="unknown"