From 914e0fbe48b118797464209c9f5c378daa18c1e2 Mon Sep 17 00:00:00 2001 From: MrFastwind Date: Thu, 9 Jul 2026 15:42:50 +0200 Subject: [PATCH] Make deployment-friendly defaults: no env vars needed to run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Go binary defaults DATA_DIR=./data, SERVERFILE_DIR=./serverfiles (relative to cwd) — just copy the binary and run - MODS_DIR, CFG_DIR, PROFILES_DIR are derived from SERVERFILE_DIR - Removed DEV_DEPLOY_DIR indirection (was only used for development) - Makefile expands defaults to ../dev-deploy/... directly for dev --- Makefile | 18 ++++++++---------- backend/cmd/server/main.go | 11 +++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 3120209..6611a5a 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,11 @@ .PHONY: backend frontend build run clean dev -DEV_DEPLOY_DIR ?= ../dev-deploy - -# Default paths — override via env or copy .env.example -SERVERFILE_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles -MODS_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/mods -CFG_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/cfg -PROFILES_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/profiles -DATA_DIR ?= $(DEV_DEPLOY_DIR)/data +# Default paths for dev — override via env +SERVERFILE_DIR ?= ../dev-deploy/serverfiles +MODS_DIR ?= ../dev-deploy/serverfiles/mods +CFG_DIR ?= ../dev-deploy/serverfiles/cfg +PROFILES_DIR ?= ../dev-deploy/serverfiles/profiles +DATA_DIR ?= ../dev-deploy/data backend: cd backend && go build -o arma3-web-server ./cmd/server/ @@ -24,12 +22,12 @@ copyfrontend: build: frontend copyfrontend backend run: - cd backend && DEV_DEPLOY_DIR=$(DEV_DEPLOY_DIR) SERVERFILE_DIR=$(SERVERFILE_DIR) MODS_DIR=$(MODS_DIR) CFG_DIR=$(CFG_DIR) PROFILES_DIR=$(PROFILES_DIR) DATA_DIR=$(DATA_DIR) GIN_MODE=debug go run ./cmd/server/ + cd backend && SERVERFILE_DIR=$(SERVERFILE_DIR) MODS_DIR=$(MODS_DIR) CFG_DIR=$(CFG_DIR) PROFILES_DIR=$(PROFILES_DIR) DATA_DIR=$(DATA_DIR) GIN_MODE=debug go run ./cmd/server/ dev: mkdir -p backend/embed/dist test -f backend/embed/dist/dev.txt || touch backend/embed/dist/dev.txt - cd backend && DEV_DEPLOY_DIR=$(DEV_DEPLOY_DIR) SERVERFILE_DIR=$(SERVERFILE_DIR) MODS_DIR=$(MODS_DIR) CFG_DIR=$(CFG_DIR) PROFILES_DIR=$(PROFILES_DIR) DATA_DIR=$(DATA_DIR) GIN_MODE=debug go run ./cmd/server/ & + cd backend && SERVERFILE_DIR=$(SERVERFILE_DIR) MODS_DIR=$(MODS_DIR) CFG_DIR=$(CFG_DIR) PROFILES_DIR=$(PROFILES_DIR) DATA_DIR=$(DATA_DIR) GIN_MODE=debug go run ./cmd/server/ & cd frontend && npm run dev clean: diff --git a/backend/cmd/server/main.go b/backend/cmd/server/main.go index 6a88945..5aae182 100644 --- a/backend/cmd/server/main.go +++ b/backend/cmd/server/main.go @@ -21,12 +21,11 @@ import ( ) func main() { - devDeploy := getEnv("DEV_DEPLOY_DIR", filepath.Join("..", "dev-deploy")) - dataDir := mustAbs(getEnv("DATA_DIR", filepath.Join(devDeploy, "data"))) - serverfileDir := mustAbs(getEnv("SERVERFILE_DIR", filepath.Join(devDeploy, "serverfiles"))) - modsDir := mustAbs(getEnv("MODS_DIR", filepath.Join(devDeploy, "serverfiles", "mods"))) - cfgDir := mustAbs(getEnv("CFG_DIR", filepath.Join(devDeploy, "serverfiles", "cfg"))) - profilesDir := mustAbs(getEnv("PROFILES_DIR", filepath.Join(devDeploy, "serverfiles", "profiles"))) + serverfileDir := mustAbs(getEnv("SERVERFILE_DIR", "./serverfiles")) + dataDir := mustAbs(getEnv("DATA_DIR", "./data")) + modsDir := mustAbs(getEnv("MODS_DIR", filepath.Join(serverfileDir, "mods"))) + cfgDir := mustAbs(getEnv("CFG_DIR", filepath.Join(serverfileDir, "cfg"))) + profilesDir := mustAbs(getEnv("PROFILES_DIR", filepath.Join(serverfileDir, "profiles"))) listen := getEnv("LISTEN", ":8080") log.Printf("data dir: %s", dataDir)