Add a Makefile and a Dockerfile to build images.

This commit is contained in:
Igor Mandrigin 2018-02-22 17:05:02 +01:00
parent 0311d2114e
commit c76e8d1b93
3 changed files with 33 additions and 2 deletions

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
DOCKER_IMAGE_NAME ?= status-bots
docker-image:
docker build --file _assets/Dockerfile . -t $(DOCKER_IMAGE_NAME):latest
allbots:
go build -i -o ./pinger -v ./cmd/pinger
go build -i -o ./chanreader -v ./cmd/chanreader

21
_assets/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
# Build status-go in a Go builder container
FROM golang:1.9-alpine as builder
ARG build_tags
RUN apk add --no-cache make gcc musl-dev linux-headers
WORKDIR /go/src/github.com/mandrigin/status-go-bots
ADD . .
RUN make allbots
# 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/mandrigin/status-go-bots/pinger /usr/local/bin/
COPY --from=builder /go/src/github.com/mandrigin/status-go-bots/chanreader /usr/local/bin/
# 30304 is used for Discovery v5
EXPOSE 8080 8545 30303 30303/udp 30304/udp

View File

@ -13,12 +13,13 @@ func main() {
cli.Run(&bots.Config{}, func(ctx *cli.Context) error {
conf := ctx.Argv().(*bots.Config)
node := bots.Quickstart(conf, 10*time.Second, func(ch *bots.StatusChannel) {
node := bots.Quickstart(*conf, 10*time.Second, func(ch *bots.StatusChannel) {
message := fmt.Sprintf("Gopher, gopher: %d", time.Now().Unix())
ch.SendMessage(message)
})
// wait till node has been stopped
node.Wait()
}
return nil
})
}