forked from TrueCloudLab/neoneo-go
Merge pull request #312 from im-kulikov/Update-Makefile_Dockerfile_Readme
- Make Dockerfile useful and minimal - Update Makefile commands build / image - Docker should not ignore vendor (go build -mod=vendor) - Used git to receive version from tags (see #304) - Version now displayed when start node (fix #102) ``` Example: → ./bin/node --version neo-go version 0.44.10-245-g67d5e9f → ./bin/node -v neo-go version 0.44.10-245-g67d5e9f ``` - add go minimal version - fix dependency manager
This commit is contained in:
commit
46ce10cbc3
5 changed files with 54 additions and 21 deletions
|
@ -1,3 +1,2 @@
|
||||||
vendor
|
|
||||||
.git
|
.git
|
||||||
chains
|
chains
|
||||||
|
|
42
Dockerfile
42
Dockerfile
|
@ -1,16 +1,40 @@
|
||||||
FROM vidsyhq/go-base:latest
|
# Builder image
|
||||||
LABEL maintainers="anthdm,stevenjack"
|
FROM golang:1.12-alpine3.10 as builder
|
||||||
|
|
||||||
ENV NETMODE=testnet
|
RUN set -x \
|
||||||
|
&& apk add --no-cache git \
|
||||||
|
&& mkdir -p /tmp
|
||||||
|
|
||||||
ARG VERSION
|
COPY . /neo-go
|
||||||
|
|
||||||
|
WORKDIR /neo-go
|
||||||
|
|
||||||
|
ARG REPO=repository
|
||||||
|
ARG VERSION=dev
|
||||||
|
|
||||||
|
# https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
|
||||||
|
# go build -mod=vendor
|
||||||
|
RUN set -x \
|
||||||
|
&& export BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||||
|
&& export GOGC=off \
|
||||||
|
&& export CGO_ENABLED=0 \
|
||||||
|
&& export LDFLAGS="-X ${REPO}/config.Version=${VERSION} -X ${REPO}/config.BuildTime=${BUILD_TIME}" \
|
||||||
|
&& go build -v -mod=vendor -ldflags "${LDFLAGS}" -o /go/bin/node ./cli/main.go
|
||||||
|
|
||||||
|
# Executable image
|
||||||
|
FROM alpine:3.10
|
||||||
|
|
||||||
|
ENV NETMODE=testnet
|
||||||
|
ARG VERSION
|
||||||
LABEL version=$VERSION
|
LABEL version=$VERSION
|
||||||
|
|
||||||
ADD bin/neo-go /usr/bin/neo-go
|
WORKDIR /
|
||||||
ADD config /config
|
|
||||||
|
|
||||||
RUN chmod u+x /usr/bin/neo-go
|
ENV NETMODE=testnet
|
||||||
RUN mkdir -p /chains
|
COPY --from=builder /neo-go/config /config
|
||||||
|
COPY --from=builder /go/bin/node /usr/bin/node
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/node"]
|
||||||
|
|
||||||
ENTRYPOINT ["neo-go"]
|
|
||||||
CMD ["node", "--config-path", "./config", "--testnet"]
|
CMD ["node", "--config-path", "./config", "--testnet"]
|
||||||
|
|
26
Makefile
26
Makefile
|
@ -1,19 +1,24 @@
|
||||||
BRANCH = "master"
|
BRANCH = "master"
|
||||||
BUILD_TIME = "$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")"
|
BUILD_TIME = "$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")"
|
||||||
VERSION = $(shell cat ./VERSION)
|
|
||||||
REPONAME = "neo-go"
|
REPONAME = "neo-go"
|
||||||
NETMODE ?= "privnet"
|
NETMODE ?= "privnet"
|
||||||
|
|
||||||
build:
|
REPO ?= "$(shell go list -m)"
|
||||||
@echo "=> Building darwin binary"
|
VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')"
|
||||||
@go build -i -ldflags "-X github.com/CityOfZion/neo-go/config.Version=${VERSION}-dev -X github.com/CityOfZion/neo-go/config.BuildTime=${BUILD_TIME}" -o ./bin/neo-go ./cli/main.go
|
BUILD_FLAGS = "-X $(REPO)/config.Version=$(VERSION) -X $(REPO)/config.BuildTime=$(BUILD_TIME)"
|
||||||
|
|
||||||
build-image:
|
build: deps
|
||||||
docker build -t cityofzion/neo-go --build-arg VERSION=${VERSION} .
|
@echo "=> Building binary"
|
||||||
|
@set -x \
|
||||||
|
&& export GOGC=off \
|
||||||
|
&& export CGO_ENABLED=0 \
|
||||||
|
&& echo $(VERSION)-$(BUILD_TIME) \
|
||||||
|
&& go build -v -mod=vendor -ldflags $(BUILD_FLAGS) -o ./bin/node ./cli/main.go
|
||||||
|
|
||||||
build-linux:
|
image: deps
|
||||||
@echo "=> Building linux binary"
|
@echo "=> Building image"
|
||||||
@GOOS=linux go build -i -ldflags "-X github.com/CityOfZion/neo-go/config.Version=${VERSION}-dev -X github.com/CityOfZion/neo-go/config.BuildTime=${BUILD_TIME}" -o ./bin/neo-go ./cli/main.go
|
@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) .
|
||||||
|
|
||||||
check-version:
|
check-version:
|
||||||
git fetch && (! git rev-list ${VERSION})
|
git fetch && (! git rev-list ${VERSION})
|
||||||
|
@ -25,7 +30,8 @@ clean-cluster:
|
||||||
@docker-compose rm -f
|
@docker-compose rm -f
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
@dep ensure
|
@go mod tidy -v
|
||||||
|
@go mod vendor
|
||||||
|
|
||||||
push-tag:
|
push-tag:
|
||||||
git checkout ${BRANCH}
|
git checkout ${BRANCH}
|
||||||
|
|
|
@ -31,9 +31,11 @@ A complete toolkit for the NEO blockchain, including:
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Go: 1.11+
|
||||||
|
|
||||||
Install dependencies.
|
Install dependencies.
|
||||||
|
|
||||||
`neo-go` uses [dep](https://github.com/golang/dep) as its dependency manager. After installing `deps` you can run:
|
`neo-go` uses [GoModules](https://github.com/golang/go/wiki/Modules) as dependency manager:
|
||||||
|
|
||||||
```
|
```
|
||||||
make deps
|
make deps
|
||||||
|
|
|
@ -7,12 +7,14 @@ import (
|
||||||
"github.com/CityOfZion/neo-go/cli/smartcontract"
|
"github.com/CityOfZion/neo-go/cli/smartcontract"
|
||||||
"github.com/CityOfZion/neo-go/cli/vm"
|
"github.com/CityOfZion/neo-go/cli/vm"
|
||||||
"github.com/CityOfZion/neo-go/cli/wallet"
|
"github.com/CityOfZion/neo-go/cli/wallet"
|
||||||
|
"github.com/CityOfZion/neo-go/config"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctl := cli.NewApp()
|
ctl := cli.NewApp()
|
||||||
ctl.Name = "neo-go"
|
ctl.Name = "neo-go"
|
||||||
|
ctl.Version = config.Version
|
||||||
ctl.Usage = "Official Go client for Neo"
|
ctl.Usage = "Official Go client for Neo"
|
||||||
|
|
||||||
ctl.Commands = []cli.Command{
|
ctl.Commands = []cli.Command{
|
||||||
|
|
Loading…
Reference in a new issue