diff --git a/.goreleaser.yml b/.goreleaser.yml index b7fcd96..c351967 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,6 +8,7 @@ before: - go mod download # you may remove this if you don't need go generate - go generate ./... +project_name: Moe builds: - env: - CGO_ENABLED=0 @@ -16,20 +17,20 @@ builds: - windows - darwin goarch: - - 386 + - '386' - amd64 - arm - arm64 ldflags: - - -X main.Version={{.Version}} -X main.BuildTag={{.FullCommit}} -X main.BuildTime={{ .Date }} -X main.CommitTime={{ .CommitDate }} + - -X config.Version={{.Version}} -X config.BuildTag={{.FullCommit}} -X config.BuildTime={{ .Date }} -X config.CommitTime={{ .CommitDate }} archives: - - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - name_template: >- + {{- .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end -}} format_overrides: - goos: windows format: zip @@ -46,3 +47,30 @@ changelog: exclude: - '^docs:' - '^test:' +dockers: + - goos: linux + # GOARCH of the built binaries/packages that should be used. + goarch: amd64 + # GOARM of the built binaries/packages that should be used. + goarm: '' + image_templates: + - "hitokoto/moe:latest" + - "hitokoto/moe:{{ .Tag }}" + - "hitokoto/moe:v{{ .Major }}" + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/hitokoto-osc/Moe/master/README.md" + - "--label=io.artifacthub.package.logo-url=https://cdn.a632079.me/assets/images/hitokoto-logo-512x512.png" + - '--label=io.artifacthub.package.maintainers=[{"name":"a632079","email":"a632079@qq.com"}]' + - "--label=io.artifacthub.package.license=GPL-3.0-only" + - "--label=org.opencontainers.image.description=Moe is a status merge tools, supporting down server count." + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/amd64" + extra_files: + - config.example.toml diff --git a/Dockerfile b/Dockerfile index e69de29..8282e18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:3.18 +ENV TZ Asia/Shanghai +RUN apk add alpine-conf tzdata && \ + /sbin/setup-timezone -z Asia/Shanghai && \ + apk del alpine-conf \ + +ENV WORKDIR /app +VOLUME $WORKDIR/data +ADD config.example.toml /app/config +ADD Moe /app +ENTRYPOINT ["sh", "-c", "/Moe", "start"] + + diff --git a/prestart/init_config_driver.go b/prestart/init_config_driver.go index 632ffd7..f3919d7 100644 --- a/prestart/init_config_driver.go +++ b/prestart/init_config_driver.go @@ -46,7 +46,10 @@ func initConfigDriver() { viper.AddConfigPath("/etc/.Moe") viper.AddConfigPath("$HOME/.Moe") viper.AddConfigPath(".") + viper.AddConfigPath("./conf") + viper.AddConfigPath("./config") viper.AddConfigPath("../conf") + viper.AddConfigPath("../config") err := viper.ReadInConfig() if err != nil { logger.Fatal("[init] Fatal error while reading config file.", zap.Error(err))