Docker setup (#70)

* Adds docker setup

* Add build args

* Remove spaec

* Bump version

* Adds run prefix
This commit is contained in:
Steven Jack 2018-04-16 09:41:23 +01:00 committed by Anthony De Meulemeester
parent 8ea013ab60
commit 7883f305e7
6 changed files with 114 additions and 2 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
vendor
.git
chains

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM vidsyhq/go-base:latest
LABEL maintainers="anthdm,stevenjack"
ENV NETMODE=testnet
ARG VERSION
LABEL version=$VERSION
ADD bin/neo-go /usr/bin/neo-go
ADD config /config
RUN chmod u+x /usr/bin/neo-go
ENTRYPOINT ["neo-go"]
CMD ["node", "--config-path", "./config", "--testnet"]

View file

@ -1,11 +1,15 @@
BRANCH = "master"
BUILD_TIME = "$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")"
VERSION = $(shell cat ./VERSION)
REPONAME = "neo-go"
NETMODE ?= "privnet"
build:
@go build -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-image:
docker build -t cityofzion/neo-go --build-arg VERSION=${VERSION} .
check-version:
git fetch && (! git rev-list ${VERSION})
@ -18,6 +22,12 @@ push-tag:
git tag ${VERSION}
git push origin ${VERSION}
push-to-registry:
@docker login -e ${DOCKER_EMAIL} -u ${DOCKER_USER} -p ${DOCKER_PASS}
@docker tag CityOfZion/${REPONAME}:latest CityOfZion/${REPONAME}:${CIRCLE_TAG}
@docker push CityOfZion/${REPONAME}:${CIRCLE_TAG}
@docker push CityOfZion/${REPONAME}
run: build
./bin/neo-go node -config-path ./config -${NETMODE}

View file

@ -49,6 +49,21 @@ make deps
## How to setup a node
### Docker
Each tagged build is built to docker hub and the `:latest` tag pointing at the latest tagged build.
By default the `CMD` is set to run a node on `testnet`, so to do this simply run:
```bash
docker run -d --name neo-go -p 20332:20332 -p 20333:20333 cityofzion/neo-go
```
Which will start a node on `testnet` and expose the nodes port `20333` and `20332` for the `JSON-RPC` server.
### Building
Build the **neo-go** CLI:
```

View file

@ -1 +1 @@
0.40.2
0.41.0

View file

@ -16,6 +16,29 @@ jobs:
paths:
- vendor
- /go/pkg
build_image:
working_directory: /go/src/github.com/CityOfZion/neo-go
docker:
- image: alpine
steps:
- run: apk update && apk add git make curl tar
- checkout
- restore_cache:
keys:
- dependency-cache-{{ .Revision }}
- restore_cache:
keys:
- dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "VERSION" }}
- setup_remote_docker
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run: make build-image
test:
working_directory: /go/src/github.com/CityOfZion/neo-go
docker:
@ -50,7 +73,34 @@ jobs:
- restore_cache:
key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "VERSION" }}
- run: make build
- save_cache:
key: dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "VERSION" }}
paths:
- bin/neo-go
deploy:
working_directory: /go/src/github.com/CityOfZion/neo-go
docker:
- image: alpine
steps:
- run: apk update && apk add git make
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "VERSION" }}
- restore_cache:
key: dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "VERSION" }}
- setup_remote_docker
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run: make build-image
- deploy:
name: deploy
command: make push-to-registry
workflows:
version: 2
workflow:
@ -81,3 +131,22 @@ workflows:
filters:
tags:
only: /[0-9]+\.[0-9]+\.[0-9]+/
- build_image:
requires:
- install_deps
- build_cli
filters:
tags:
only: /[0-9]+\.[0-9]+\.[0-9]+/
- deploy:
requires:
- build_image
- test
- vet
- check_version
filters:
tags:
only:
- /[0-9]+\.[0-9]+\.[0-9]+/
branches:
ignore: /.*/