From 08657060d24ee379c8e12e9d817a186081ddd73d Mon Sep 17 00:00:00 2001 From: tectiv3 Date: Thu, 28 Feb 2019 23:55:41 +0900 Subject: [PATCH 1/3] Remove glide files --- .gitignore | 1 + .goreleaser.yml | 2 +- build-linux-cgo.sh | 29 +++++++++++++++++++---------- glide.lock | 29 ----------------------------- glide.yaml | 11 ----------- go.mod | 6 +++--- 6 files changed, 24 insertions(+), 54 deletions(-) delete mode 100644 glide.lock delete mode 100644 glide.yaml diff --git a/.gitignore b/.gitignore index beb24b5..c488f3d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pid log dist standardfile.exe +vendor diff --git a/.goreleaser.yml b/.goreleaser.yml index 659f542..e6f89a8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -19,7 +19,7 @@ builds: env: - CGO_ENABLED=0 hooks: - pre: ./build-linux-cgo.sh + post: ./build-linux-cgo.sh release: github: owner: tectiv3 diff --git a/build-linux-cgo.sh b/build-linux-cgo.sh index 66e054e..42452c1 100755 --- a/build-linux-cgo.sh +++ b/build-linux-cgo.sh @@ -6,17 +6,26 @@ BUILD_TIME=`date +%FT%T%z` xgo -ldflags="-w -X main.BuildTime=$BUILD_TIME -X main.Version=$VERSION" --targets="linux/386,linux/amd64,linux/arm-6,linux/arm-7,linux/arm64" . -mkdir dist/linux_386 -mv standardfile-linux-386 dist/linux_386/standardfile +VERSION=${VERSION#v} -mkdir dist/linux_amd64 -mv standardfile-linux-amd64 dist/linux_amd64/standardfile +mv standardfile-linux-386 standardfile +tar czf standardfile_${VERSION}_linux_32-bit.tar.gz standardfile +rm -f standardfile -mkdir dist/linux_arm6 -mv standardfile-linux-arm-6 dist/linux_arm6/standardfile +mv standardfile-linux-amd64 standardfile +tar czf standardfile_${VERSION}_linux_64-bit.tar.gz standardfile +rm -f standardfile -mkdir dist/linux_arm7 -mv standardfile-linux-arm-7 dist/linux_arm7/standardfile +mv standardfile-linux-arm-6 standardfile +tar czf standardfile_${VERSION}_linux_arm6.tar.gz standardfile +rm -f standardfile -mkdir dist/linux_arm8 -mv standardfile-linux-arm64 dist/linux_arm8/standardfile +mv standardfile-linux-arm-7 standardfile +tar czf standardfile_${VERSION}_linux_arm7.tar.gz standardfile +rm -f standardfile + +mv standardfile-linux-arm64 standardfile +tar czf standardfile_${VERSION}_linux_arm8.tar.gz standardfile +rm -f standardfile + +mv standardfile_${VERSION}* dist/ \ No newline at end of file diff --git a/glide.lock b/glide.lock deleted file mode 100644 index f9f7987..0000000 --- a/glide.lock +++ /dev/null @@ -1,29 +0,0 @@ -hash: bf9bd5cd5da5b6a0a19440357ffedad747239bd6b62bbfbab6d24dd281dc2bd7 -updated: 2018-06-28T15:54:27.997069277+09:00 -imports: -- name: github.com/deckarep/golang-set - version: 504e848d77ea4752b3057b8fb46da0e7f746ccf3 -- name: github.com/dgrijalva/jwt-go - version: 06ea1031745cb8b3dab3f6a236daf2b0aa468b7e -- name: github.com/go-playground/ansi - version: 777788a9be1a7296979a999c86b251fc777077a9 -- name: github.com/go-playground/form - version: 572fa772c66ec5e3606a1a548406e10fb62de317 -- name: github.com/go-playground/pure - version: dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 - subpackages: - - _examples/middleware/logging-recovery - - middleware -- name: github.com/kardianos/osext - version: ae77be60afb1dcacde03767a8c37337fad28ac14 -- name: github.com/kisielk/sqlstruct - version: 648daed35d49dac24a4bff253b190a80da3ab6a5 -- name: github.com/mattn/go-sqlite3 - version: 25ecb14adfc7543176f7d85291ec7dba82c6f7e4 -- name: github.com/remind101/migrate - version: 52c1edff7319858d56cbb1954ed32d520788a164 -- name: github.com/satori/go.uuid - version: 36e9d2ebbde5e3f13ab2e25625fd453271d6522e -- name: github.com/sevlyar/go-daemon - version: f9261e73885de99b1647d68bedadf2b9a99ad11f -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 1dc00ba..0000000 --- a/glide.yaml +++ /dev/null @@ -1,11 +0,0 @@ -package: github.com/tectiv3/standardfile -import: -- package: github.com/deckarep/golang-set -- package: github.com/dgrijalva/jwt-go -- package: github.com/go-playground/pure - subpackages: - - _examples/middleware/logging-recovery -- package: github.com/kisielk/sqlstruct -- package: github.com/mattn/go-sqlite3 -- package: github.com/satori/go.uuid -- package: github.com/sevlyar/go-daemon diff --git a/go.mod b/go.mod index a9e3dda..63a6fc1 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,12 @@ go 1.12 require ( github.com/deckarep/golang-set v1.7.1 github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/go-playground/ansi v2.1.0+incompatible - github.com/go-playground/form v3.1.4+incompatible + github.com/go-playground/ansi v2.1.0+incompatible // indirect + github.com/go-playground/form v3.1.4+incompatible // indirect github.com/go-playground/pure v0.0.0-20170911042516-dd99f50b7780 github.com/go-yaml/yaml v2.1.0+incompatible // indirect github.com/heetch/confita v0.5.1 - github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/kisielk/sqlstruct v0.0.0-20150923205031-648daed35d49 github.com/mattn/go-sqlite3 v1.10.0 github.com/pkg/errors v0.8.1 // indirect From c16917774655aa30c12b4d9d626c0065bf4eec6c Mon Sep 17 00:00:00 2001 From: tectiv3 Date: Tue, 19 Mar 2019 19:59:18 +0900 Subject: [PATCH 2/3] Add caddy config example --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 867e50e..086c65e 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ To disable registration run with `standardfile -noreg` Run with -cors flag to enable automatic cors handling (needed for standardnotes app for example). ### Deploying to a live server -I suggest putting it behind nginx or caddy with https enabled location +I suggest putting it behind nginx or [caddy](https://caddyserver.com/) with https enabled location. +- nginx sample config ``` server { server_name sf.example.com; @@ -114,6 +115,17 @@ server { } } ``` +- caddy sample config +``` +sf.example.com { + gzip + + proxy / localhost:8888 { + transparent + } +} +``` + ### Optional Environment variables **SECRET_KEY_BASE** From eea575ce0419a8392893fcc4dfc69b58ac99a11c Mon Sep 17 00:00:00 2001 From: tectiv3 Date: Fri, 17 May 2019 14:22:45 +0900 Subject: [PATCH 3/3] Fix CORS setting reading from json Display current configuration values with `-v` option --- main.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 458a683..65f203d 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "os" "runtime" + "strconv" "syscall" "github.com/sevlyar/go-daemon" @@ -24,7 +25,7 @@ type Config struct { NoReg bool `config:"noreg"` Debug bool `config:"debug"` Foreground bool `config:"foreground"` - UseCORS bool `config:"cors"` + UseCORS bool `config:"cors" json:"cors" yaml:"cors" toml:"cors"` } var cfg = Config{ @@ -70,11 +71,17 @@ func main() { flag.Parse() if *ver { - fmt.Println(` Version: ` + Version + ` - Built: ` + BuildTime + ` - Go version: ` + runtime.Version() + ` - OS/Arch: ` + runtime.GOOS + "/" + runtime.GOARCH) - + fmt.Println(` Version: ` + Version + ` + Built: ` + BuildTime + ` + Go Version: ` + runtime.Version() + ` + OS/Arch: ` + runtime.GOOS + "/" + runtime.GOARCH + ` + No Registrations: ` + strconv.FormatBool(cfg.NoReg) + ` + CORS Enabled: ` + strconv.FormatBool(cfg.UseCORS) + ` + Run in Foreground: ` + strconv.FormatBool(cfg.Foreground) + ` + Webserver Port: ` + strconv.Itoa(cfg.Port) + ` + CORS Enabled: ` + strconv.FormatBool(cfg.UseCORS) + ` + DB Path: ` + cfg.DB + ` + Debug: ` + strconv.FormatBool(cfg.Debug)) return }