Skip to content

Commit

Permalink
feat: dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Sep 13, 2023
1 parent 06a92d7 commit 657f899
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
46 changes: 37 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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":"[email protected]"}]'
- "--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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]


3 changes: 3 additions & 0 deletions prestart/init_config_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 657f899

Please sign in to comment.