Skip to content

Commit

Permalink
chore: add image-build
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-armstrong authored and Stonepapa committed Feb 22, 2024
1 parent 04a6471 commit d410cc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ FROM golang:1.21 AS build
# INSTALL DEPENDENCIES
RUN go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
COPY go.mod go.sum /src/
RUN cd /src && go mod download
WORKDIR /src
RUN go mod download

# BUILD BINARY
COPY . /src
COPY . /src/
RUN cd /src/db && packr2
RUN cd /src && make build
RUN find /src/dist

# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18
COPY --from=build /src/dist/zkevm-node /app/zkevm-node
COPY --from=build /src/dist/b2-zkevm-node /app/b2-zkevm-node
COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
RUN apk update && apk add postgresql15-client
EXPOSE 8123
CMD ["/bin/sh", "-c", "/app/zkevm-node run"]
CMD ["/app/b2-zkevm-node"]
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/dist
GOENVVARS := GOBIN=$(GOBIN) CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH)
GOBINARY := zkevm-node
GOBINARY := b2-zkevm-node
GOCMD := $(GOBASE)/cmd

LDFLAGS += -X 'github.com/0xPolygonHermez/zkevm-node.Version=$(VERSION)'
Expand All @@ -28,7 +28,12 @@ PYTHON = $(or $(wildcard $(VENV_PYTHON)), "install_first_venv")
GENERATE_SCHEMA_DOC = $(VENV)/bin/generate-schema-doc
GENERATE_DOC_PATH = "docs/config-file/"
GENERATE_DOC_TEMPLATES_PATH = "docs/config-file/templates/"

DATE=$(shell date +%Y%m%d-%H%M%S)
COMMITID=$(shell git log -1 --format='%h')
BRANCH=$(shell git branch --show-current)
GIT_TAG=$(shell git describe --tags --abbrev=0)
IMAGE_REPO=ghcr.io/b2network/b2-zkevm-node
IMAGE_TAG=${IMAGE_REPO}:${BRANCH}-${GIT_TAG}-${DATE}-${COMMITID}
# Check dependencies
# Check for Go
.PHONY: check-go
Expand Down Expand Up @@ -78,9 +83,10 @@ generate-code-from-proto: check-protoc
build: ## Builds the binary locally into ./dist
$(GOENVVARS) go build -ldflags "all=$(LDFLAGS)" -o $(GOBIN)/$(GOBINARY) $(GOCMD)

.PHONY: build-docker
build-docker: ## Builds a docker image with the node binary
docker build -t zkevm-node -f ./Dockerfile .
image-build: ## Builds a docker image with the node binary
docker build -t ${IMAGE_TAG} -f ./Dockerfile .
image-push: ## Builds a docker image with the node binary
docker push --all-tags ${IMAGE_REPO}

.PHONY: build-docker-nc
build-docker-nc: ## Builds a docker image with the node binary - but without build cache
Expand Down Expand Up @@ -118,7 +124,7 @@ venv: $(VENV_PYTHON)
.PHONY: install-config-doc-gen
$(GENERATE_SCHEMA_DOC): $(VENV_PYTHON)
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install json-schema-for-humans==0.47
$(PYTHON) -m pip install json-schema-for-humans

.PHONY: config-doc-gen
config-doc-gen: config-doc-node config-doc-custom_network ## Generate config file's json-schema for node and custom_network and documentation
Expand Down

0 comments on commit d410cc0

Please sign in to comment.