Make deployment-friendly defaults: no env vars needed to run
Some checks failed
CI / build (push) Failing after 3s
Some checks failed
CI / build (push) Failing after 3s
- 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
This commit is contained in:
18
Makefile
18
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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user