fix docker

This commit is contained in:
Help-14 2022-04-16 10:33:13 +07:00
parent f5a52c980a
commit 0fc3b781b5
2 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,7 @@
services:
magma:
container_name: magma
image: magma
image: help14/magma
restart: unless-stopped
volumes:
- ./data/:/app/data

View file

@ -1,12 +1,12 @@
package main
import (
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"time"
@ -24,15 +24,18 @@ var websiteData = struct {
func main() {
pwd, _ = os.Getwd()
exec.Command("mkdir", "-p", "./data").Run()
exec.Command("cp", "--recursive", "./common/*", "./data/").Run()
dataPath := filepath.Join(pwd, "data")
if _, err := os.Stat(filepath.Join(dataPath, "data.yaml")); os.IsNotExist(err) {
fmt.Println("Copy files to data folder")
modules.CopyDirectory(filepath.Join(pwd, "common"), dataPath)
}
appConfig = modules.LoadConfig()
websiteData.Config = appConfig.Website
websiteData.Language = modules.LoadLanguage(appConfig.Website.Language)
websiteData.Contents = modules.LoadContent().Data
commonfs := http.FileServer(http.Dir(filepath.Join(pwd, "data")))
commonfs := http.FileServer(http.Dir(filepath.Join(dataPath, "common")))
http.Handle("/common/", http.StripPrefix("/common/", commonfs))
languagefs := http.FileServer(http.Dir(filepath.Join(pwd, "languages")))