Add compose file

This commit is contained in:
cuigh 2018-01-04 15:54:28 +08:00
parent bbce4dbd35
commit 918fd82ea5
4 changed files with 48 additions and 8 deletions

2
Gopkg.lock generated
View File

@ -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"

View File

@ -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**

34
compose.yml Normal file
View File

@ -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:

14
main.go
View File

@ -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())