From 99d7e5fdc98f6f2e20729d06504b6428fc52902c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Thu, 19 Mar 2026 18:24:19 +0100 Subject: [PATCH] update server app path to host's --- .env.example | 6 +++++- docker-compose.yml | 4 ++-- local/service/docker_runtime.go | 9 ++++++++- local/service/server.go | 12 +++++------- local/utl/env/env.go | 7 +++++++ 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 0897b48..95f73c6 100755 --- a/.env.example +++ b/.env.example @@ -64,10 +64,14 @@ PASSWORD=change-this-default-admin-password # Docker image name for ACC server containers (built from docker/acc-server/Dockerfile) # ACC_IMAGE=acc-wine:latest -# Base path where per-server game installations are stored. +# Base path where per-server game installations are stored (inside the manager container). # Each server gets its own subdirectory: ACC_SERVERS_PATH// # ACC_SERVERS_PATH=/data/servers +# Host-side path for the same directory — used when creating sibling ACC server containers. +# Must match the host path bound to ACC_SERVERS_PATH in docker-compose.yml. +# ACC_SERVERS_HOST_PATH=/opt/acc-servers + # Port pool for Docker-mode ACC server containers (one port per server). # PORT_POOL_MIN=9600 # PORT_POOL_MAX=9700 diff --git a/docker-compose.yml b/docker-compose.yml index 45e7260..82f653a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,17 +16,17 @@ services: PORT_POOL_MAX: "9700" ACC_IMAGE: acc-wine:latest ACC_SERVERS_PATH: /data/servers + ACC_SERVERS_HOST_PATH: /opt/acc-servers env_file: - .env volumes: - /var/run/docker.sock:/var/run/docker.sock - - acc-servers:/data/servers + - /opt/acc-servers:/data/servers - acc-db:/data/db networks: - acc-net volumes: - acc-servers: acc-db: networks: diff --git a/local/service/docker_runtime.go b/local/service/docker_runtime.go index 5e2b6e9..b129666 100644 --- a/local/service/docker_runtime.go +++ b/local/service/docker_runtime.go @@ -7,7 +7,9 @@ import ( "acc-server-manager/local/utl/logging" "context" "fmt" + "path/filepath" "strconv" + "strings" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" @@ -50,8 +52,13 @@ func (r *DockerRuntime) Create(ctx context.Context, server *model.Server) error natPortUDP: struct{}{}, } + containerBase := env.GetACCServersPath() + hostBase := env.GetACCServersHostPath() + serverSubPath := strings.TrimPrefix(server.GetServerPath(), containerBase) + hostServerPath := filepath.Join(hostBase, serverSubPath) + binds := []string{ - fmt.Sprintf("%s:/acc/game:rw", server.GetServerPath()), + fmt.Sprintf("%s:/acc/game:rw", hostServerPath), } resp, err := r.client.ContainerCreate(ctx, &container.Config{ diff --git a/local/service/server.go b/local/service/server.go index b74ecdd..3318111 100755 --- a/local/service/server.go +++ b/local/service/server.go @@ -487,9 +487,9 @@ func (s *ServerService) rollbackSteps(ctx context.Context, server *model.Server, case model.StepServiceCreation: s.runtime.Delete(ctx, server.ID) case model.StepSteamDownload: - if !env.IsDockerPlatform() { - s.steamService.UninstallServer(server.Path) - } + s.steamService.UninstallServer(server.Path) + case model.StepDirectoryCreation: + s.steamService.UninstallServer(server.Path) case model.StepConfigGeneration: if env.IsDockerPlatform() && server.Port > 0 { s.portPool.Release(ctx, server.Port) @@ -520,10 +520,8 @@ func (s *ServerService) DeleteServer(ctx *fiber.Ctx, serverID uuid.UUID) error { } } - if server.Platform != "docker" { - if err := s.steamService.UninstallServer(server.Path); err != nil { - logging.Error("Failed to uninstall server: %v", err) - } + if err := s.steamService.UninstallServer(server.Path); err != nil { + logging.Error("Failed to uninstall server: %v", err) } if env.IsDockerPlatform() && server.Port > 0 { diff --git a/local/utl/env/env.go b/local/utl/env/env.go index f258c0a..a176d11 100755 --- a/local/utl/env/env.go +++ b/local/utl/env/env.go @@ -65,6 +65,13 @@ func GetACCServersPath() string { return DefaultACCServersPath } +func GetACCServersHostPath() string { + if p := os.Getenv("ACC_SERVERS_HOST_PATH"); p != "" { + return p + } + return GetACCServersPath() +} + func ValidatePaths() map[string]error { errors := make(map[string]error)