|
1 |
| -# Simple usage with a mounted data directory: |
2 |
| -# > docker build -t qosd . |
3 |
| -# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.qosd:/root/.qosd -v ~/.qoscli:/root/.qoscli qosd qosd init |
4 |
| -# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.qosd:/root/.qosd -v ~/.qoscli:/root/.qoscli qosd gstarsd start |
5 |
| -FROM golang:alpine AS build-env |
| 1 | +# Base build image |
| 2 | +FROM golang:1.11.5-alpine3.9 as builder |
6 | 3 |
|
7 |
| -# Set up dependencies |
8 |
| -ENV PACKAGES git bash gcc make libc-dev linux-headers eudev-dev |
9 |
| -#make libc-dev bash gcc linux-headers eudev-dev |
| 4 | +# Install some dependencies needed to build the project |
| 5 | +RUN apk add make gcc git libc-dev bash linux-headers eudev-dev |
10 | 6 |
|
11 |
| -# Set working directory for the build |
12 |
| -WORKDIR /go/src/github.com/QOSGroup/qos |
| 7 | +# Set up GOPATH & PATH |
| 8 | +ENV GOPATH /root/go |
| 9 | +ENV BASE_PATH $GOPATH/src/github.com/ |
| 10 | +ENV REPO_PATH $BASE_PATH/qos |
| 11 | +ENV PATH $GOPATH/bin:$PATH |
| 12 | + |
| 13 | +# Force the go compiler to use modules |
| 14 | +ENV GO111MODULE=on |
| 15 | + |
| 16 | +# Set the Current Working Directory inside the container |
| 17 | +WORKDIR $REPO_PATH |
| 18 | + |
| 19 | +# We want to populate the module cache based on the go.{mod,sum} files. |
| 20 | +COPY go.mod . |
| 21 | +COPY go.sum . |
| 22 | + |
| 23 | +#This is the ‘magic’ step that will download all the dependencies that are specified in |
| 24 | +# the go.mod and go.sum file. |
| 25 | +# Because of how the layer caching system works in Docker, the go mod download |
| 26 | +# command will _ only_ be re-run when the go.mod or go.sum file change |
| 27 | +# (or when we add another docker instruction this line) |
| 28 | +RUN go mod download |
13 | 29 |
|
14 | 30 | # Add source files
|
15 |
| -COPY . . |
16 |
| - |
17 |
| -# Install minimum necessary dependencies, build Cosmos SDK, remove packages |
18 |
| -RUN apk add --no-cache $PACKAGES && \ |
19 |
| - # make tools && \ |
20 |
| - # make vendor-deps && \ |
21 |
| - # make build && \ |
22 |
| - # make install |
23 |
| - cd cmd/qosd && \ |
24 |
| - export GOPROXY=http://192.168.1.177:8081 && \ |
25 |
| - export GO111MODULE=on && \ |
26 |
| - go build && \ |
27 |
| - cd ../qoscli && \ |
28 |
| - go build |
29 |
| - |
30 |
| -# Final image |
31 |
| -FROM alpine:edge |
32 |
| - |
33 |
| -# Install ca-certificates |
34 |
| -#RUN apk add --update ca-certificates |
35 |
| -WORKDIR /root |
36 |
| - |
37 |
| -# Copy over binaries from the build-env |
38 |
| -COPY --from=build-env /go/src/github.com/QOSGroup/qos/cmd/qosd/qosd /usr/bin/qosd |
39 |
| -COPY --from=build-env /go/src/github.com/QOSGroup/qos/cmd/qoscli/qoscli /usr/bin/qoscli |
40 |
| - |
41 |
| -# Run gaiad by default, omit entrypoint to ease using container with gaiacli |
42 |
| -CMD ["qosd"] |
| 31 | +COPY . $REPO_PATH/ |
| 32 | + |
| 33 | +# build qosd & qoscli |
| 34 | +RUN go build -o qosd $REPO_PATH/cmd/qosd/main.go |
| 35 | +RUN go build -o qoscli $REPO_PATH/cmd/qoscli/main.go |
| 36 | + |
| 37 | +# new stage |
| 38 | +FROM alpine:3.9 |
| 39 | + |
| 40 | +# p2p port |
| 41 | +EXPOSE 26656 |
| 42 | +# rpc port |
| 43 | +EXPOSE 26657 |
| 44 | + |
| 45 | +COPY --from=builder /root/go/src/github.com/qos/qosd /usr/local/bin/ |
| 46 | +COPY --from=builder /root/go/src/github.com/qos/qoscli /usr/local/bin/ |
0 commit comments