Skip to content

Commit 4b55493

Browse files
authored
Merge pull request #42 from Gearbox-protocol/docker_build
build: publish docker images and github releases
2 parents f1d05cc + d4c237c commit 4b55493

File tree

5 files changed

+100
-2
lines changed

5 files changed

+100
-2
lines changed

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v2
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set up Go
29+
uses: actions/setup-go@v3
30+
with:
31+
go-version: "1.17"
32+
cache: true
33+
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v2
36+
with:
37+
version: latest
38+
args: release --rm-dist
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
REPO_NAME: ${{ github.repository }}

.goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
# before:
4+
# hooks:
5+
# You may remove this if you don't use go modules.
6+
# - go mod tidy
7+
builds:
8+
- main: ./cmd
9+
binary: 3eye
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
ldflags:
18+
- -s -w -X github.com/{{ .Env.REPO_NAME }}/version.Version={{ .Version }}
19+
changelog:
20+
groups:
21+
- title: Features
22+
regexp: "^.*feat[(\\w)]*:+.*$"
23+
order: 0
24+
- title: "Bug fixes"
25+
regexp: "^.*fix[(\\w)]*:+.*$"
26+
order: 1
27+
- title: Others
28+
order: 999
29+
filters:
30+
exclude:
31+
- "^docs:"
32+
- "^build:"
33+
- "^chore:"
34+
- "^test:"
35+
dockers:
36+
- goos: linux
37+
goarch: amd64
38+
39+
image_templates:
40+
- "ghcr.io/{{ tolower .Env.REPO_NAME }}:latest"
41+
- "ghcr.io/{{ tolower .Env.REPO_NAME }}:{{ .Tag }}"
42+
- "ghcr.io/{{ tolower .Env.REPO_NAME }}:{{ .Major }}"

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM gcr.io/distroless/base-debian11
2+
3+
ENTRYPOINT ["/3eye"]
4+
COPY 3eye /

healthcheck/index.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ package healthcheck
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
6-
"io"
77
"net/http"
88

99
"github.com/Gearbox-protocol/sdk-go/log"
1010
"github.com/Gearbox-protocol/third-eye/config"
11+
"github.com/Gearbox-protocol/third-eye/version"
1112
"go.uber.org/fx"
1213
)
1314

15+
type healthResp struct {
16+
Status string `json:"status"`
17+
Version string `json:"version"`
18+
}
19+
1420
func newHealthcheckEndpoint(lc fx.Lifecycle, config *config.Config) {
1521
if config.Port == "0" {
1622
return
@@ -22,8 +28,9 @@ func newHealthcheckEndpoint(lc fx.Lifecycle, config *config.Config) {
2228
Handler: mux,
2329
}
2430
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
31+
w.Header().Set("Content-Type", "application/json")
2532
w.WriteHeader(http.StatusOK)
26-
io.WriteString(w, "OK")
33+
json.NewEncoder(w).Encode(healthResp{"OK", version.Version})
2734
})
2835

2936
lc.Append(fx.Hook{

version/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package version
2+
3+
// Version is provided by goreleaser via ldflags
4+
var Version = "dev"

0 commit comments

Comments
 (0)