.github: add action to build WSC image

This commit is contained in:
AnnaShaleva 2021-11-19 15:23:51 +03:00 committed by Anna Shaleva
parent b940167a6b
commit e64a617844
5 changed files with 78 additions and 10 deletions

View file

@ -0,0 +1,15 @@
#!C:\Program Files\PowerShell\7\pwsh.EXE -File
$bin = '/usr/bin/neo-go.exe'
for ( $i = 0; $i -lt $args.count; $i++ ) {
if ($args[$i] -eq "node"){
Write-Host "=> Try to restore blocks before running node"
if (($Env:ACC -ne $null) -and (Test-Path $Env:ACC -PathType Leaf)) {
& $bin db restore -p --config-path /config -i $Env:ACC
}
break
}
}
& $bin $args

View file

@ -40,9 +40,9 @@ jobs:
- name: Build CLI
run: make build
build_cli_win:
name: Build CLI (Windows)
runs-on: windows-2019
build_cli_wsc:
name: Build CLI (Windows Server Core)
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
@ -66,9 +66,9 @@ jobs:
- name: Build CLI
run: make build
build_image:
build_image_ubuntu:
needs: build_cli_ubuntu
name: Build Docker image
name: Build Docker image (Ubuntu)
runs-on: ubuntu-20.04
steps:
@ -78,3 +78,16 @@ jobs:
- name: Build Docker image
run: make image
build_image_wsc:
needs: build_cli_wsc
name: Build Docker image (Windows Server Core)
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build Docker image
run: make image-wsc

View file

@ -99,9 +99,9 @@ jobs:
- name: Run tests
run: go test -v -race ./...
tests_win:
name: Windows, Go (1.17)
runs-on: windows-2019
tests_wsc:
name: Windows Server Core, Go (1.17)
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:

36
Dockerfile.wsc Normal file
View file

@ -0,0 +1,36 @@
# Builder image
FROM golang:windowsservercore-ltsc2022 as builder
COPY . /neo-go
WORKDIR /neo-go
ARG REPO=repository
ARG VERSION=dev
SHELL ["cmd", "/S", "/C"]
RUN go env -w CGO_ENABLED=0
ENV GOGC=off
RUN go build -trimpath -v -o ./bin/neo-go.exe -ldflags="-X %REPO%/pkg/config.Version=%VERSION%" ./cli/main.go
# Executable image
FROM mcr.microsoft.com/windows/servercore:ltsc2022
ARG VERSION
LABEL version=%VERSION%
WORKDIR /
COPY --from=builder /neo-go/config /config
COPY --from=builder /neo-go/.docker/privnet-entrypoint.ps1 /usr/bin/privnet-entrypoint.ps1
COPY --from=builder /neo-go/bin/neo-go.exe /usr/bin/neo-go.exe
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';", "$ProgressPreference = 'SilentlyContinue';"]
# Check executable version.
RUN /usr/bin/neo-go.exe --version
ENTRYPOINT ["powershell", "-File", "/usr/bin/privnet-entrypoint.ps1"]
CMD ["node", "--config-path", "/config", "--privnet"]

View file

@ -18,7 +18,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-latest image-push image-push-latest check-version clean-cluster push-tag \
.PHONY: build deps image image-wsc image-latest image-push image-push-latest check-version clean-cluster push-tag \
test vet lint fmt cover
build: deps
@ -49,9 +49,13 @@ postinst: install
&& systemctl enable neo-go.service
image: deps
@echo "=> Building image"
@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) .
image-latest: deps
@echo "=> Building image with 'latest' tag"
@docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .