From afbbdc5e02ed027e642225cf14214a00c316072b Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 28 Jan 2020 13:03:18 +0300 Subject: [PATCH 1/3] Update command to build and publish images - Use nspcc-dev docker hub repository - Add command to publish neo-go images --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 352192676..1ee80c955 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ REPO ?= "$(shell go list -m)" VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')" BUILD_FLAGS = "-X $(REPO)/config.Version=$(VERSION)" +IMAGE_REPO=nspccdev/neo-go + # All of the targets are phony here because we don't really use make dependency # tracking for files .PHONY: build deps image check-version clean-cluster push-tag push-to-registry \ @@ -48,8 +50,13 @@ postinst: install image: deps @echo "=> Building image" - @docker build -t cityofzion/neo-go:latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . - @docker build -t cityofzion/neo-go:$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . + @docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . + @docker build -t $(IMAGE_REPO):$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . + +image-push: + @echo "=> Publish image" + @docker push $(IMAGE_REPO):latest + @docker push $(IMAGE_REPO):$(VERSION) check-version: git fetch && (! git rev-list ${VERSION}) From 9e92749b05bda2fd38e4c1aebcd52ad62754b69e Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 28 Jan 2020 13:04:13 +0300 Subject: [PATCH 2/3] Add single node chain dump to image --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c4a40aa47..a9c4bdb4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,8 @@ LABEL version=$VERSION WORKDIR / COPY --from=builder /neo-go/config /config -COPY --from=builder /neo-go/.docker/6000-privnet-blocks.acc.gz /privnet-blocks.acc.gz +COPY --from=builder /neo-go/.docker/6000-privnet-blocks.acc.gz /6000-privnet-blocks.acc.gz +COPY --from=builder /neo-go/.docker/1600-privnet-blocks-single.acc.gz /1600-privnet-blocks-single.acc.gz COPY --from=builder /neo-go/.docker/privnet-entrypoint.sh /usr/bin/privnet-entrypoint.sh COPY --from=builder /go/bin/neo-go /usr/bin/neo-go COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ From 2cb2a6d3205e436aabdce1014cf7a9d6d684894f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 28 Jan 2020 13:09:19 +0300 Subject: [PATCH 3/3] Add possibility to import different dump of chains - import dump only if `node` sub command passed - ACC env variable default value is `6000-privnet-blocks.acc.gz` - ACC env variable can be declared in `docker-compose` - ACC env variable can be one of: - `/6000-privnet-blocks.acc.gz` - `/1600-privnet-blocks-single.acc.gz` - custom path to dump of blockchain --- .docker/privnet-entrypoint.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.docker/privnet-entrypoint.sh b/.docker/privnet-entrypoint.sh index 4a0c80f82..65f38b80f 100755 --- a/.docker/privnet-entrypoint.sh +++ b/.docker/privnet-entrypoint.sh @@ -1,6 +1,19 @@ #!/bin/sh -if test -f /privnet-blocks.acc.gz; then - gunzip /privnet-blocks.acc.gz - /usr/bin/neo-go db restore -i /privnet-blocks.acc + +BIN=/usr/bin/neo-go + +if [ -z "$ACC"]; then + ACC=/6000-privnet-blocks.acc.gz fi -/usr/bin/neo-go "$@" + +case $@ in + "node"*) + echo "=> Try to restore blocks before running node" + if test -f $ACC; then + gunzip --stdout /$ACC > /privnet.acc + ${BIN} db restore -p --config-path /config -i /privnet.acc + fi + ;; +esac + +${BIN} "$@"