diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index df3f064..bd8fab7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -16,7 +16,7 @@ jobs: with: go-version: '1.21' - name: build - run: go build -v ./... + run: make build - name: golangci-lint run: make lint - name: format diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8d1a760 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Pull golang alpine to build binary +FROM golang:1.21-alpine3.19 as builder + +RUN apk add --no-cache make + +WORKDIR /app + +# Build binary +COPY . . +RUN make build + +# Use alpine to run app +FROM alpine:3.19 +WORKDIR /app +COPY --from=builder /app/bin/faultdetector . +COPY --from=builder /app/config.yaml . + +EXPOSE 8080 + +# Run app +CMD [ "./faultdetector" ] diff --git a/Makefile b/Makefile index 83d8818..409fe58 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,16 @@ PKGS=$(shell go list ./... | grep -v "/vendor/") .PHONY: test +APP_NAME = faultdetector +GREEN = \033[0;32m +BLUE = \033[0;34m +COLOR_END = \033[0;39m + +build: + @echo "$(BLUE)ยป Building fault detector application binary... $(COLOR_END)" + @CGO_ENABLED=0 go build -a -o bin/$(APP_NAME) ./cmd/ + @echo "$(GREEN) Binary successfully built$(COLOR_END)" + test: @echo "Test packages" @go test -race -shuffle=on -coverprofile=coverage.out -cover $(PKGS) diff --git a/bin/faultdetector b/bin/faultdetector new file mode 100755 index 0000000..02c21b2 Binary files /dev/null and b/bin/faultdetector differ diff --git a/config.yaml b/config.yaml index adadf51..2580407 100644 --- a/config.yaml +++ b/config.yaml @@ -15,5 +15,5 @@ api: fault_detector: l1_rpc_endpoint: "https://rpc.notadegen.com/eth" l2_rpc_endpoint: "https://mainnet.optimism.io/" - start_batch_index: 0 + start_batch_index: 5874 l2_output_oracle_contract_address: "0x0000000000000000000000000000000000000000" diff --git a/go.mod b/go.mod index 388bead..8e7279f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/LiskHQ/op-fault-detector -go 1.21.5 +go 1.21 require ( github.com/ethereum-optimism/optimism v1.4.2