Skip to content

Commit

Permalink
Merge pull request #100 from multiversx/publish-docker-image
Browse files Browse the repository at this point in the history
Added docker deploy github action
  • Loading branch information
iulianpascalau authored Jul 29, 2024
2 parents 0b81593 + b5ece0a commit 298e5bc
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 2,515 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/events-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 }}

6 changes: 3 additions & 3 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ 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
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
go mod download
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ 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
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
go mod download
- name: Unit tests
run: make test
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ If the service will be in "notifier" mode, it will expose a additional route:

In this setup, `Redis` is used as a locker service. If `CheckDuplicates` config
parameter is set to `true` notifier instance will check for duplicated events
in locker service.
in locker service. Alternatively, this option can be set/unset via the binary flag
called `--check-duplicates`.

Check `Redis` section from config in order to set up the available options.

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,
}

checkDuplicates = cli.BoolTFlag{
Name: "check-duplicates",
Usage: "Boolean option to check the duplicates. Set this to '--check-duplicates=false' to disable the check",
}
)

// appVersion should be populated at build time using ldflags
Expand Down Expand Up @@ -110,6 +114,7 @@ func main() {
workingDirectory,
apiType,
publisherType,
checkDuplicates,
}
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(checkDuplicates.Name) {
mainConfig.General.CheckDuplicates = ctx.GlobalBool(checkDuplicates.Name)
}

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

go 1.16
go 1.20

require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.0
github.com/go-redis/redis/v8 v8.11.3
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/multiversx/mx-chain-communication-go v1.0.7
github.com/multiversx/mx-chain-core-go v1.2.13
github.com/multiversx/mx-chain-logger-go v1.0.13
github.com/pelletier/go-toml v1.9.3
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.44.0
github.com/spaolacci/murmur3 v1.1.0
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.10
google.golang.org/protobuf v1.30.0
)

require (
github.com/gin-contrib/cors v1.4.0
github.com/multiversx/mx-chain-communication-go v1.0.7
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.44.0
google.golang.org/protobuf v1.30.0
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.15.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 298e5bc

Please sign in to comment.