-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
7,491 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM golang:1.21.4-alpine as builder | ||
|
||
# Version to build. Default is the Git HEAD. | ||
ARG VERSION="HEAD" | ||
|
||
# Use muslc for static libs | ||
ARG BUILD_TAGS="muslc" | ||
|
||
|
||
RUN apk add --no-cache --update openssh git make build-base linux-headers libc-dev \ | ||
pkgconfig zeromq-dev musl-dev alpine-sdk libsodium-dev \ | ||
libzmq-static libsodium-static gcc | ||
|
||
|
||
RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts | ||
RUN git config --global url."[email protected]:".insteadOf "https://github.com/" | ||
ENV GOPRIVATE=github.com/babylonchain/* | ||
|
||
# Build | ||
WORKDIR /go/src/github.com/babylonchain/covenant-emulator | ||
# Cache dependencies | ||
COPY go.mod go.sum /go/src/github.com/babylonchain/covenant-emulator/ | ||
RUN --mount=type=secret,id=sshKey,target=/root/.ssh/id_rsa go mod download | ||
# Copy the rest of the files | ||
COPY ./ /go/src/github.com/babylonchain/covenant-emulator/ | ||
|
||
# Cosmwasm - Download correct libwasmvm version | ||
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ | ||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ | ||
-O /lib/libwasmvm_muslc.a && \ | ||
# verify checksum | ||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ | ||
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1) | ||
|
||
RUN CGO_LDFLAGS="$CGO_LDFLAGS -lstdc++ -lm -lsodium" \ | ||
CGO_ENABLED=1 \ | ||
BUILD_TAGS=$BUILD_TAGS \ | ||
LINK_STATICALLY=true \ | ||
make build | ||
|
||
# FINAL IMAGE | ||
FROM alpine:3.16 AS run | ||
|
||
RUN addgroup --gid 1138 -S covenant-emulator && adduser --uid 1138 -S covenant-emulator -G covenant-emulator | ||
|
||
RUN apk add bash curl jq | ||
|
||
COPY --from=builder /go/src/github.com/babylonchain/covenant-emulator/build/covd /bin/covd | ||
|
||
WORKDIR /home/covenant-emulator | ||
RUN chown -R covenant-emulator /home/covenant-emulator | ||
USER covenant-emulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
BUILDDIR ?= $(CURDIR)/build | ||
TOOLS_DIR := tools | ||
|
||
BABYLON_PKG := github.com/babylonchain/babylon/cmd/babylond | ||
|
||
GO_BIN := ${GOPATH}/bin | ||
|
||
DOCKER := $(shell which docker) | ||
CUR_DIR := $(shell pwd) | ||
MOCKS_DIR=$(CUR_DIR)/testutil/mocks | ||
MOCKGEN_REPO=github.com/golang/mock/mockgen | ||
MOCKGEN_VERSION=v1.6.0 | ||
MOCKGEN_CMD=go run ${MOCKGEN_REPO}@${MOCKGEN_VERSION} | ||
|
||
ldflags := $(LDFLAGS) | ||
build_tags := $(BUILD_TAGS) | ||
build_args := $(BUILD_ARGS) | ||
|
||
PACKAGES_E2E=$(shell go list ./... | grep '/itest') | ||
|
||
ifeq ($(LINK_STATICALLY),true) | ||
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" -v | ||
endif | ||
|
||
ifeq ($(VERBOSE),true) | ||
build_args += -v | ||
endif | ||
|
||
BUILD_TARGETS := build install | ||
BUILD_FLAGS := --tags "$(build_tags)" --ldflags '$(ldflags)' | ||
|
||
all: build install | ||
|
||
build: BUILD_ARGS := $(build_args) -o $(BUILDDIR) | ||
|
||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/ | ||
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... | ||
|
||
$(BUILDDIR)/: | ||
mkdir -p $(BUILDDIR)/ | ||
|
||
build-docker: | ||
$(DOCKER) build --secret id=sshKey,src=${BBN_PRIV_DEPLOY_KEY} --tag babylonchain/covenant-emulator -f Dockerfile \ | ||
$(shell git rev-parse --show-toplevel) | ||
|
||
.PHONY: build build-docker | ||
|
||
test: | ||
go test ./... | ||
|
||
test-e2e: | ||
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG) | ||
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e | ||
|
||
mock-gen: | ||
mkdir -p $(MOCKS_DIR) | ||
$(MOCKGEN_CMD) -source=clientcontroller/interface.go -package mocks -destination $(MOCKS_DIR)/babylon.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# covenant-emulator | ||
# Covenant Emulator |
Oops, something went wrong.