Skip to content

Commit 98fb880

Browse files
authored
Merge pull request 0xDkd#87 from ysicing/dev
support sqlite3 & docker
2 parents 585bac5 + 010d755 commit 98fb880

39 files changed

+232
-66
lines changed

.dockerignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Go template
3+
# Binaries for programs and plugins
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Dependency directories (remove the comment below to include it)
17+
# vendor/
18+
19+
### Example user template template
20+
### Example user template
21+
22+
# IntelliJ project files
23+
.idea
24+
*.iml
25+
out
26+
gen
27+
28+
auxpi
29+
db/auxpi.db
30+
conf/install.lock
31+
conf/siteConfig.json

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ main
3030
*.test
3131

3232
# Output of the go coverage tool, specifically when used with LiteIDE
33-
*.out
33+
*.out
34+
35+
db/auxpi.db
36+
conf/install.lock
37+
conf/siteConfig.json

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM auxpi:base AS builder
2+
3+
RUN make build
4+
5+
FROM debian:stretch-backports
6+
7+
ENV TZ Asia/Shanghai
8+
9+
COPY --from=builder /go/src/github.com/auxpi/auxpi /opt/go/auxpi
10+
11+
COPY static /opt/go/static
12+
13+
COPY views /opt/go/views
14+
15+
#COPY db /opt/go/db
16+
RUN mkdir -p /opt/go/db /opt/go/conf
17+
18+
# 持久化数据库
19+
VOLUME /opt/go/db
20+
# 持久化配置
21+
VOLUME /opt/go/conf
22+
23+
COPY conf /opt/go/confbak
24+
25+
COPY hack/run/entrypoint.sh /entrypoint.sh
26+
27+
RUN chmod 777 /opt/go/auxpi \
28+
&& chmod 777 /entrypoint.sh
29+
30+
WORKDIR /opt/go
31+
32+
EXPOSE 2333
33+
34+
ENTRYPOINT ["/entrypoint.sh"]
35+
36+
CMD ["run"]

Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.PHONY: fmt vet lint default
2+
GO_RELEASE_TAGS := $(shell go list -f ':{{join (context.ReleaseTags) ":"}}:' runtime)
3+
4+
# Only use the `-race` flag on newer versions of Go (version 1.3 and newer)
5+
ifeq (,$(findstring :go1.3:,$(GO_RELEASE_TAGS)))
6+
RACE_FLAG :=
7+
else
8+
RACE_FLAG := -race -cpu 1,2,4
9+
endif
10+
11+
# Run `go vet` on Go 1.12 and newer. For Go 1.5-1.11, use `go tool vet`
12+
ifneq (,$(findstring :go1.12:,$(GO_RELEASE_TAGS)))
13+
GO_VET := go vet \
14+
-atomic \
15+
-bool \
16+
-copylocks \
17+
-nilfunc \
18+
-printf \
19+
-rangeloops \
20+
-unreachable \
21+
-unsafeptr \
22+
-unusedresult \
23+
.
24+
else ifneq (,$(findstring :go1.5:,$(GO_RELEASE_TAGS)))
25+
GO_VET := go tool vet \
26+
-atomic \
27+
-bool \
28+
-copylocks \
29+
-nilfunc \
30+
-printf \
31+
-shadow \
32+
-rangeloops \
33+
-unreachable \
34+
-unsafeptr \
35+
-unusedresult \
36+
.
37+
else
38+
GO_VET := @echo "go vet skipped -- not supported on this version of Go"
39+
endif
40+
41+
fmt: ## fmt
42+
43+
@echo gofmt -l
44+
@OUTPUT=`gofmt -l . 2>&1`; \
45+
if [ "$$OUTPUT" ]; then \
46+
echo "gofmt must be run on the following files:"; \
47+
echo "$$OUTPUT"; \
48+
exit 1; \
49+
fi
50+
51+
lint: ## lint
52+
53+
@echo golint ./...
54+
@OUTPUT=`command -v golint >/dev/null 2>&1 && golint ./... 2>&1`; \
55+
if [ "$$OUTPUT" ]; then \
56+
echo "golint errors:"; \
57+
echo "$$OUTPUT"; \
58+
exit 1; \
59+
fi
60+
61+
vet: ## vet
62+
$(GO_VET)
63+
64+
default: fmt lint vet
65+
66+
.PHONY: build
67+
build: ## 构建
68+
GOARCH=amd64 GOOS=linux CGO_ENABLED=1 go build
69+
70+
.PHONY: docker
71+
docker: ## 构建镜像
72+
@docker build -t auxpi:base -f hack/docker/Dockerfile .
73+
@docker build -t ysicing/auxpi .
74+
75+
help: ## this help
76+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

auxpiAll/e/code.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const (
1919
ERROR_AUTH = 20004
2020
ERROR_ACCESS_DENIED = 20005
2121

22-
2322
ERROR_TASK_REPEAT = 30001
2423

2524
//USER ERROR 4xxx
@@ -34,7 +33,7 @@ const (
3433
ERROR_USER_DELTE = 40007
3534

3635
//上传参数错误(api 选择)
37-
ERROR_UPLOAD_PARAM = 50001
38-
ERROR_CAN_NOT_UPLOAD = 50002
36+
ERROR_UPLOAD_PARAM = 50001
37+
ERROR_CAN_NOT_UPLOAD = 50002
3938
ERROR_UPLOAD_TOKEN_ERROR = 50003
4039
)

bootstrap/Config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type AuxpiConfig struct {
3333
}
3434

3535
var Cache = initCache()
36+
3637
//var Cache, _ = cache.NewCache("memory", `{"interval":60}`)
3738

3839
var SiteConfig *auxpi.SiteConfig
@@ -175,7 +176,7 @@ func init() {
175176

176177
//Db Init
177178
siteconfig.DbOption.UseDb = true
178-
siteconfig.DbOption.DbType = "mysql"
179+
siteconfig.DbOption.DbType = "sqlite3"
179180
siteconfig.DbOption.DbHost = "127.0.0.1:3306"
180181
siteconfig.DbOption.DbName = "auxpi"
181182
siteconfig.DbOption.DbUser = "root"
@@ -248,6 +249,6 @@ func initCache() cache.Cache {
248249
panic(err)
249250
}
250251
return c
251-
252+
252253
}
253254
}

controllers/api/v1/upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (a *ApiUploadController) UpLoadHandle() {
4040
//验证
4141
validate := a.Validate(h.Header.Get("Content-Type"), h.Filename)
4242
if validate {
43-
resp,_ := a.UploadHandle(userID, apiSelect, h, ip, true)
43+
resp, _ := a.UploadHandle(userID, apiSelect, h, ip, true)
4444
a.Data["json"] = resp
4545
a.ServeJSON()
4646
}

controllers/index.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type PagesController struct {
2525
beego.Controller
2626
}
2727

28-
2928
func (i *PagesController) commonStyle() {
3029
un, _ := i.GetSecureCookie(bootstrap.SiteConfig.AuxpiSalt, "uname")
3130

db/.gitkeep

Whitespace-only changes.

go.mod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ require (
44
github.com/astaxie/beego v1.11.1
55
github.com/casbin/casbin v1.7.0
66
github.com/casbin/gorm-adapter v0.0.0-20190318080705-e74a050c51a4
7-
github.com/denisenkom/go-mssqldb v0.0.0-20190412130859-3b1d194e553a // indirect
87
github.com/dgrijalva/jwt-go v3.2.0+incompatible
9-
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect
108
github.com/go-sql-driver/mysql v1.4.1
119
github.com/gofrs/uuid v3.2.0+incompatible
1210
github.com/gorilla/websocket v1.4.0
13-
github.com/jinzhu/gorm v1.9.2
14-
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
15-
github.com/jinzhu/now v1.0.0 // indirect
11+
github.com/jinzhu/gorm v1.9.10
1612
github.com/kr/pretty v0.1.0 // indirect
1713
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
1814
github.com/pkg/errors v0.8.0
@@ -23,3 +19,5 @@ require (
2319
gopkg.in/masci/flickr.v2 v2.0.0-20161216033441-3cc496dc15cd
2420
gopkg.in/yaml.v2 v2.2.2
2521
)
22+
23+
go 1.13

0 commit comments

Comments
 (0)