Skip to content

Commit

Permalink
- added docker deploy github action
Browse files Browse the repository at this point in the history
- bump go version to v1.20.7
- added deduplication check binary flag
  • Loading branch information
iulianpascalau committed Jul 29, 2024
1 parent 0b81593 commit 7705c4b
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 2,505 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish Docker image

on:
release:
types: [published]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.20.7
id: go

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: multiversx/notifier

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17.6
- name: Set up Go 1.20.7
uses: actions/setup-go@v2
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
name: Unit
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17.6
- name: Set up Go 1.20.7
uses: actions/setup-go@v2
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17.6 as builder
FROM golang:1.20.7 as builder

MAINTAINER MultiversX

Expand All @@ -10,7 +10,7 @@ WORKDIR /multiversx/cmd/notifier
RUN go build -o notifier

# ===== SECOND STAGE ======
FROM ubuntu:20.04
FROM ubuntu:22.04
COPY --from=builder /multiversx/cmd/notifier /multiversx

EXPOSE 8080
Expand Down
17 changes: 13 additions & 4 deletions cmd/notifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import (
)

const (
defaultLogsPath = "logs"
logFilePrefix = "event-notifier"
logFileLifeSpanSec = 86400
defaultRestInterface = "localhost:8080"
defaultLogsPath = "logs"
logFilePrefix = "event-notifier"
logFileLifeSpanSec = 86400
)

var (
Expand Down Expand Up @@ -83,6 +82,11 @@ VERSION:
Usage: "This flag specifies the publisher type, it defines the way in which it will expose the events. Options: " + common.MessageQueuePublisherType + " | " + common.WSPublisherType,
Value: common.MessageQueuePublisherType,
}

noDuplicationCheck = cli.BoolFlag{
Name: "no-duplicates-check",
Usage: "Boolean option for skipping duplication checks",
}
)

// appVersion should be populated at build time using ldflags
Expand Down Expand Up @@ -110,6 +114,7 @@ func main() {
workingDirectory,
apiType,
publisherType,
noDuplicationCheck,
}
app.Authors = []cli.Author{
{
Expand Down Expand Up @@ -173,6 +178,10 @@ func readConfigs(ctx *cli.Context) (*config.Configs, error) {
return nil, err
}

if ctx.IsSet(noDuplicationCheck.Name) {
mainConfig.General.CheckDuplicates = false
}

apiConfig, err := config.LoadAPIConfig(flagsConfig.APIConfigPath)
if err != nil {
return nil, err
Expand Down
43 changes: 42 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/multiversx/mx-chain-notifier-go

go 1.16
go 1.20

require (
github.com/gin-gonic/gin v1.9.0
Expand All @@ -18,7 +18,48 @@ require (
require (
github.com/gin-contrib/cors v1.4.0
github.com/multiversx/mx-chain-communication-go v1.0.7
github.com/pelletier/go-toml v1.9.3
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.44.0
google.golang.org/protobuf v1.30.0
)

require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denisbrodbeck/machineid v1.0.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiversx/mx-chain-crypto-go v1.2.8 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 7705c4b

Please sign in to comment.