From da4c0d1db9c736d0f4e45ebdc8fd7108dbbc2cd2 Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Wed, 3 Jan 2018 19:50:19 +0100 Subject: [PATCH] Update Dockerfile (#521) --- .dockerignore | 7 ++++++- Dockerfile | 29 +++++++++++++++++------------ Makefile | 15 ++++++++++----- cmd/wnode-status/config.go | 3 ++- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index 72e8ffc0d..b145dd0bd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,6 @@ -* +.git +.ethereumtest +.github +build/bin +statusd-data +wnode-data diff --git a/Dockerfile b/Dockerfile index e714cdda8..078970790 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,20 @@ -FROM alpine:3.5 +# Build wnode-status in a Go builder container +FROM golang:1.9-alpine as builder -RUN \ - apk add --update go git make gcc musl-dev linux-headers ca-certificates && \ - git clone --depth 1 --branch feature/statusd-replaces-geth-on-cluster https://github.com/farazdagi/status-go && \ - (cd status-go && make) && \ - cp status-go/build/bin/statusd /statusd && \ - apk del go git make gcc musl-dev linux-headers && \ - rm -rf /status-go && rm -rf /var/cache/apk/* +RUN apk add --no-cache make gcc musl-dev linux-headers -EXPOSE 8545 -EXPOSE 30303 -EXPOSE 3001 +RUN mkdir -p /go/src/github.com/status-im/status-go +ADD . /go/src/github.com/status-im/status-go +RUN cd /go/src/github.com/status-im/status-go && make statusgo && make wnode-status -ENTRYPOINT ["/statusd"] +# Copy the binary to the second image +FROM alpine:latest + +RUN apk add --no-cache ca-certificates bash +COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/* /usr/local/bin/ + +RUN mkdir -p /static/keys +COPY --from=builder /go/src/github.com/status-im/status-go/static/keys/* /static/keys/ + +# 30304 is used for Discovery v5 +EXPOSE 8080 8545 30303 30303/udp 30304/udp diff --git a/Makefile b/Makefile index 7039c5899..154c2a066 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,18 @@ help: ##@other Show this help include ./static/tools/mk/lint.mk ifndef GOPATH -$(error GOPATH not set. Please set GOPATH and make sure status-go is located at $$GOPATH/src/github.com/status-im/status-go. For more information about the GOPATH environment variable, see https://golang.org/doc/code.html#GOPATH) + $(error GOPATH not set. Please set GOPATH and make sure status-go is located at $$GOPATH/src/github.com/status-im/status-go. \ + For more information about the GOPATH environment variable, see https://golang.org/doc/code.html#GOPATH) endif CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin GOBIN = build/bin GO ?= latest +DOCKER_IMAGE_NAME ?= status-go + +UNIT_TEST_PACKAGES := $(shell go list ./... | grep -v /vendor | grep -v /e2e | grep -v /cmd | grep -v /lib) + # This is a code for automatic help generator. # It supports ANSI colors and categories. # To add new item into help output, simply add comments @@ -35,10 +40,6 @@ HELP_FUN = \ print "\n"; \ } -# Main targets - -UNIT_TEST_PACKAGES := $(shell go list ./... | grep -v /vendor | grep -v /e2e | grep -v /cmd | grep -v /lib) - statusgo: ##@build Build status-go as statusd server go build -i -o $(GOBIN)/statusd -v $(shell build/testnet-flags.sh) ./cmd/statusd @echo "\nCompilation done.\nRun \"build/bin/statusd -h\" to view available commands." @@ -69,6 +70,10 @@ statusgo-library: ##@cross-compile Build status-go as static library for current @echo "Static library built:" @ls -la $(GOBIN)/libstatus.* +docker-image: ##@docker Build docker image (use DOCKER_IMAGE_NAME to set the image name) + @echo "Building docker image..." + docker build . -t $(DOCKER_IMAGE_NAME) + xgo: docker pull farazdagi/xgo go get github.com/karalabe/xgo diff --git a/cmd/wnode-status/config.go b/cmd/wnode-status/config.go index 0d91e176e..dfe6944ab 100644 --- a/cmd/wnode-status/config.go +++ b/cmd/wnode-status/config.go @@ -15,7 +15,7 @@ var ( prodMode = flag.Bool("production", false, "Whether production settings should be loaded") dataDir = flag.String("datadir", "wnode-data", "Data directory for the databases and keystore") networkID = flag.Int("networkid", params.RopstenNetworkID, "Network identifier (integer, 1=Homestead, 3=Ropsten, 4=Rinkeby)") - listenAddr = flag.String("listenaddr", params.ListenAddr, "IP address and port of this node (e.g. 127.0.0.1:30303)") + listenAddr = flag.String("listenaddr", ":30303", "IP address and port of this node (e.g. 127.0.0.1:30303)") httpEnabled = flag.Bool("http", false, "HTTP RPC enpoint enabled (default: false)") httpPort = flag.Int("httpport", params.HTTPPort, "HTTP RPC server's listening port") ipcEnabled = flag.Bool("ipc", false, "IPC RPC endpoint enabled") @@ -107,6 +107,7 @@ func makeNodeConfig() (*params.NodeConfig, error) { if !*httpEnabled { nodeConfig.HTTPHost = "" // HTTP RPC is disabled } + nodeConfig.HTTPHost = "0.0.0.0" nodeConfig.HTTPPort = *httpPort nodeConfig.IPCEnabled = *ipcEnabled nodeConfig.RPCEnabled = *httpEnabled