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
|
.PHONY: backend frontend build run clean dev
|
||||||
|
|
||||||
DEV_DEPLOY_DIR ?= ../dev-deploy
|
# Default paths for dev — override via env
|
||||||
|
SERVERFILE_DIR ?= ../dev-deploy/serverfiles
|
||||||
# Default paths — override via env or copy .env.example
|
MODS_DIR ?= ../dev-deploy/serverfiles/mods
|
||||||
SERVERFILE_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles
|
CFG_DIR ?= ../dev-deploy/serverfiles/cfg
|
||||||
MODS_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/mods
|
PROFILES_DIR ?= ../dev-deploy/serverfiles/profiles
|
||||||
CFG_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/cfg
|
DATA_DIR ?= ../dev-deploy/data
|
||||||
PROFILES_DIR ?= $(DEV_DEPLOY_DIR)/serverfiles/profiles
|
|
||||||
DATA_DIR ?= $(DEV_DEPLOY_DIR)/data
|
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
cd backend && go build -o arma3-web-server ./cmd/server/
|
cd backend && go build -o arma3-web-server ./cmd/server/
|
||||||
@@ -24,12 +22,12 @@ copyfrontend:
|
|||||||
build: frontend copyfrontend backend
|
build: frontend copyfrontend backend
|
||||||
|
|
||||||
run:
|
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:
|
dev:
|
||||||
mkdir -p backend/embed/dist
|
mkdir -p backend/embed/dist
|
||||||
test -f backend/embed/dist/dev.txt || touch backend/embed/dist/dev.txt
|
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
|
cd frontend && npm run dev
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
devDeploy := getEnv("DEV_DEPLOY_DIR", filepath.Join("..", "dev-deploy"))
|
serverfileDir := mustAbs(getEnv("SERVERFILE_DIR", "./serverfiles"))
|
||||||
dataDir := mustAbs(getEnv("DATA_DIR", filepath.Join(devDeploy, "data")))
|
dataDir := mustAbs(getEnv("DATA_DIR", "./data"))
|
||||||
serverfileDir := mustAbs(getEnv("SERVERFILE_DIR", filepath.Join(devDeploy, "serverfiles")))
|
modsDir := mustAbs(getEnv("MODS_DIR", filepath.Join(serverfileDir, "mods")))
|
||||||
modsDir := mustAbs(getEnv("MODS_DIR", filepath.Join(devDeploy, "serverfiles", "mods")))
|
cfgDir := mustAbs(getEnv("CFG_DIR", filepath.Join(serverfileDir, "cfg")))
|
||||||
cfgDir := mustAbs(getEnv("CFG_DIR", filepath.Join(devDeploy, "serverfiles", "cfg")))
|
profilesDir := mustAbs(getEnv("PROFILES_DIR", filepath.Join(serverfileDir, "profiles")))
|
||||||
profilesDir := mustAbs(getEnv("PROFILES_DIR", filepath.Join(devDeploy, "serverfiles", "profiles")))
|
|
||||||
listen := getEnv("LISTEN", ":8080")
|
listen := getEnv("LISTEN", ":8080")
|
||||||
|
|
||||||
log.Printf("data dir: %s", dataDir)
|
log.Printf("data dir: %s", dataDir)
|
||||||
|
|||||||
Reference in New Issue
Block a user