From be14d8325b02edab17977a885ffa426c1f0505a8 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Mar 2022 11:19:51 +0300 Subject: [PATCH 1/4] github: add job to check Ubuntu privnet image build Related to https://github.com/nspcc-dev/neo-go/pull/2408#pullrequestreview-921289314. --- .github/workflows/build.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03d655908..1d28e72cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,3 +127,27 @@ jobs: - name: Build Docker image run: make image-wsc + + build_privnet_image_ubuntu: + needs: build_cli_ubuntu + name: Build privnet Docker image (Ubuntu) + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + # For proper `deps` make target execution. + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + # For information purposes. + - name: Print Docker version + run: docker --version + + - name: Build privnet Docker image + run: make env_image From 613f6e435002267d7c2394b9a79c2198ad5684e6 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Mar 2022 16:08:13 +0300 Subject: [PATCH 2/4] Makefile: allow to build privnet image for WSC 1. Build privnet image for WSC. 2. Automatically define OS to build image and privnet image. 3. Unify image building code for Ubuntu and WSC. --- .github/workflows/build.yml | 2 +- .github/workflows/publish_to_dockerhub.yml | 4 +-- Makefile | 36 ++++++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d28e72cb..df34d8325 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,7 +126,7 @@ jobs: go-version: 1.18 - name: Build Docker image - run: make image-wsc + run: make image build_privnet_image_ubuntu: needs: build_cli_ubuntu diff --git a/.github/workflows/publish_to_dockerhub.yml b/.github/workflows/publish_to_dockerhub.yml index 551274139..d8cf5e969 100644 --- a/.github/workflows/publish_to_dockerhub.yml +++ b/.github/workflows/publish_to_dockerhub.yml @@ -156,7 +156,7 @@ jobs: go-version: 1.18 - name: Build image - run: make image-wsc + run: make image - name: Login to DockerHub uses: docker/login-action@v1 @@ -166,4 +166,4 @@ jobs: - name: Push image to registry if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} - run: make image-wsc-push + run: make image-push diff --git a/Makefile b/Makefile index d026423f0..1beb9250a 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,10 @@ BINDIR = "/usr/bin" SYSTEMDUNIT_DIR = "/lib/systemd/system" UNITWORKDIR = "/var/lib/neo-go" -DC_FILE=.docker/docker-compose.yml +IMAGE_SUFFIX="$(shell if [ "$(OS)" = Windows_NT ]; then echo "_WindowsServerCore"; fi)" +D_FILE ?= "$(shell if [ "$(OS)" = Windows_NT ]; then echo "Dockerfile.wsc"; else echo "Dockerfile"; fi)" +DC_FILE ?= ".docker/docker-compose.yml" # Single docker-compose for Ubuntu/WSC, should be kept in sync with ENV_IMAGE_TAG. +ENV_IMAGE_TAG="env_neo_go_image" REPO ?= "$(shell go list -m)" VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')" @@ -19,7 +22,7 @@ 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 image-wsc image-latest image-push image-wsc-push image-push-latest check-version clean-cluster push-tag \ +.PHONY: build deps image image-latest image-push image-push-latest check-version clean-cluster push-tag \ test vet lint fmt cover build: deps @@ -50,24 +53,21 @@ postinst: install && systemctl enable neo-go.service image: deps - @echo "=> Building image for Ubuntu" - @docker build -t $(IMAGE_REPO):$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . - -image-wsc: deps - @echo "=> Building image for Windows Server Core" - @docker build -f Dockerfile.wsc -t $(IMAGE_REPO):$(VERSION)_WindowsServerCore --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . + @echo "=> Building image" + @echo " Dockerfile: $(D_FILE)" + @echo " Tag: $(IMAGE_REPO):$(VERSION)$(IMAGE_SUFFIX)" + @docker build -f $(D_FILE) -t $(IMAGE_REPO):$(VERSION)$(IMAGE_SUFFIX) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . image-latest: deps @echo "=> Building image with 'latest' tag" + @echo " Dockerfile: Dockerfile" # Always use default Dockerfile for Ubuntu as `latest`. + @echo " Tag: $(IMAGE_REPO):latest" @docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . image-push: - @echo "=> Publish image for Ubuntu" - @docker push $(IMAGE_REPO):$(VERSION) - -image-wsc-push: - @echo "=> Publish image for Windows Server Core" - @docker push $(IMAGE_REPO):$(VERSION)_WindowsServerCore + @echo "=> Publish image" + @echo " Tag: $(IMAGE_REPO):$(VERSION)$(IMAGE_SUFFIX)" + @docker push $(IMAGE_REPO):$(VERSION)$(IMAGE_SUFFIX) image-push-latest: @echo "=> Publish image for Ubuntu with 'latest' tag" @@ -104,16 +104,20 @@ cover: @go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./pkg/...,./cli/... @go tool cover -html=coverage.txt -o coverage.html -# --- Environment --- +# --- Ubuntu/Windows environment --- env_image: @echo "=> Building env image" + @echo " Dockerfile: $(D_FILE)" + @echo " Tag: $(ENV_IMAGE_TAG)" @docker build \ - -t env_neo_go_image \ + -f $(D_FILE) \ + -t $(ENV_IMAGE_TAG) \ --build-arg REPO=$(REPO) \ --build-arg VERSION=$(VERSION) . env_up: @echo "=> Bootup environment" + @echo " Docker-compose file: $(DC_FILE)" @docker-compose -f $(DC_FILE) up -d node_one node_two node_three node_four env_single: From b01892613e9a8cc06854e6d203507891f85d3f5b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Mar 2022 16:08:37 +0300 Subject: [PATCH 3/4] github: add job to check WSC privnet image build --- .github/workflows/build.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df34d8325..a895af440 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -151,3 +151,27 @@ jobs: - name: Build privnet Docker image run: make env_image + + build_privnet_image_wsc: + needs: build_cli_wsc + name: Build privnet Docker image (Windows Server Core) + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + # For proper `deps` make target execution. + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + # For information purposes. + - name: Print Docker version + run: docker --version + + - name: Build privnet Docker image + run: make env_image From 064f9629b30282d994f7b1286ba788e3fe223368 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Mar 2022 16:26:36 +0300 Subject: [PATCH 4/4] docs: specify required Docker version for node image building --- docs/consensus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/consensus.md b/docs/consensus.md index d2afc422f..9f16acd79 100644 --- a/docs/consensus.md +++ b/docs/consensus.md @@ -143,7 +143,7 @@ Node wallets are located in the `.docker/wallets` directory where four-node setup. #### Prerequisites -- `docker` +- `docker` of version >= 20.10.0 - `docker-compose` - `go` compiler