fix docker
This commit is contained in:
parent
f5a52c980a
commit
0fc3b781b5
2 changed files with 8 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
magma:
|
||||
container_name: magma
|
||||
image: magma
|
||||
image: help14/magma
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data/:/app/data
|
||||
|
|
11
src/main.go
11
src/main.go
|
@ -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")))
|
||||
|
|
Loading…
Add table
Reference in a new issue