fix: mount config directory instead of file for Docker Compose
Build and Push to GHCR / build-and-push (push) Has been cancelled

- Add CONFIG_PATH env support to avoid Docker creating config.json as a directory
- Config Save() now auto-creates parent directories
- Update docker-compose.yml to mount ./config:/app/config
- Update README deployment docs accordingly
This commit is contained in:
Agent
2026-05-24 15:44:29 +08:00
parent 45da2d1d0c
commit 44c8ff6a6f
6 changed files with 42 additions and 14 deletions
+5 -5
View File
@@ -63,7 +63,7 @@ func (h *Handler) CreateLink(w http.ResponseWriter, r *http.Request) {
}
h.cfg.SetLink(link)
if err := h.cfg.Save("config.json"); err != nil {
if err := h.cfg.Save(config.GetConfigFilePath()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -112,7 +112,7 @@ func (h *Handler) UpdateLink(w http.ResponseWriter, r *http.Request) {
}
h.cfg.SetLink(link)
if err := h.cfg.Save("config.json"); err != nil {
if err := h.cfg.Save(config.GetConfigFilePath()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -132,7 +132,7 @@ func (h *Handler) DeleteLink(w http.ResponseWriter, r *http.Request) {
}
h.cfg.DeleteLink(id)
if err := h.cfg.Save("config.json"); err != nil {
if err := h.cfg.Save(config.GetConfigFilePath()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -152,7 +152,7 @@ func (h *Handler) RegenerateToken(w http.ResponseWriter, r *http.Request) {
link.Token = auth.GenerateToken()
h.cfg.SetLink(link)
if err := h.cfg.Save("config.json"); err != nil {
if err := h.cfg.Save(config.GetConfigFilePath()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -221,7 +221,7 @@ func (h *Handler) UpdateConfig(w http.ResponseWriter, r *http.Request) {
h.cfg.AdminPass = req.AdminPass
}
if err := h.cfg.Save("config.json"); err != nil {
if err := h.cfg.Save(config.GetConfigFilePath()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}