diff --git a/Gopkg.lock b/Gopkg.lock index e8c7444..ad1abb5 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -23,7 +23,7 @@ branch = "master" name = "github.com/cuigh/auxo" packages = [".","app","app/flag","byte/size","cache","cache/memory","config","data","data/guid","data/valid","encoding/yaml","errors","ext/files","ext/reflects","ext/texts","ext/times","log","log/console","log/file","net/web","net/web/filter","net/web/filter/auth","net/web/renderer","net/web/renderer/jet","net/web/router","security","security/passwd","util/cast","util/debug","util/i18n","util/lazy"] - revision = "884fa635c732cc5a6f5e43f590e9393f7b789637" + revision = "f599f84ec7ef56f01457d0fb0d8eeb9d8c100b43" [[projects]] branch = "master" diff --git a/README.md b/README.md index 27d745c..a5827d7 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,12 @@ docker service create \ cuigh/swirl ``` +### Docker compose + +```bash +docker stack deploy -c compose.yml swirl +``` + ## Build **Swirl** use `dep` as dependency management tool. You can build **Swirl** diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..10881f9 --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +version: '3' + +services: + swirl: + image: cuigh/swirl + environment: + DB_ADDRESS: mongo:27017/swirl + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ports: + - 8001:8001 + networks: + - net + deploy: + replicas: 1 + placement: + constraints: [node.role == manager] + + mongo: + image: mongo + volumes: + - mongo:/data/db + networks: + - net + deploy: + replicas: 1 +# placement: +# constraints: [node.hostname == mongo] + +volumes: + mongo: + +networks: + net: \ No newline at end of file diff --git a/main.go b/main.go index 1716225..db92f0f 100644 --- a/main.go +++ b/main.go @@ -61,13 +61,13 @@ func server() *web.Server { // set render ws.Validator = &valid.Validator{Tag: "valid"} - ws.Renderer = jet.New().SetDebug(config.GetBool("debug")). - AddFunc("time", misc.FormatTime(setting.TimeZone.Offset)). - AddFunc("i18n", misc.Message(setting.Language)). - AddFuncs(misc.Funcs). - AddVariable("language", setting.Language). - AddVariable("version", app.Version). - AddVariable("go_version", runtime.Version()) + ws.Renderer = jet.Must(jet.Debug(config.GetBool("debug")), jet.VarMap(misc.Funcs), jet.VarMap(map[string]interface{}{ + "language": setting.Language, + "version": app.Version, + "go_version": runtime.Version(), + "time": misc.FormatTime(setting.TimeZone.Offset), + "i18n": misc.Message(setting.Language), + })) // register global filters ws.Use(filter.NewRecover())