From 666a034608d5712157defbcc8fea7da5c734f852 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Thu, 21 Jun 2018 14:15:00 +0100 Subject: [PATCH] add docker setup --- .dockerignore | 7 +++++++ .gitignore | 4 ++++ Dockerfile | 50 ++++++++++++++++------------------------------ docker-compose.yml | 21 +++++++++++++++++++ 4 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b193b395 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +vendor/ +Dockerfile +deployment/ +*.sublime-project +*.sublime-workspace +.kvd/ +.kvcli/ diff --git a/.gitignore b/.gitignore index 577653e3..41238d6f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ vendor # Exclude text editor files *.sublime-project *.sublime-workspace + +# Exclude chain data +.kvd/ +.kvcli/ diff --git a/Dockerfile b/Dockerfile index fe9b8d86..b36cdfc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,21 @@ -FROM alpine:edge +# Start with go container +FROM golang:alpine AS builder +WORKDIR /go/src/github.com/kava-labs/kava -# Set up dependencies -ENV PACKAGES go glide make git libc-dev bash +# Install go package manager +#RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - doesn't work as alpine has no curl +RUN apk add --no-cache git && go get -u github.com/golang/dep/cmd/dep -# Set up GOPATH & PATH -ENV GOPATH /root/go -ENV BASE_PATH $GOPATH/src/github.com/cosmos -ENV REPO_PATH $BASE_PATH/cosmos-sdk -ENV WORKDIR /cosmos/ -ENV PATH $GOPATH/bin:$PATH +# Install go packages (without updating Gopkg, as there is no source code to update from)(also with -v for verbose) +ADD Gopkg.toml Gopkg.lock ./ +RUN dep ensure --vendor-only -v -# Link expected Go repo path -RUN mkdir -p $WORKDIR $GOPATH/pkg $ $GOPATH/bin $BASE_PATH +# Copy in app code and build +COPY . . +RUN go build ./cmd/kvd && go build ./cmd/kvcli -#Install apk dependencies -RUN apk add --no-cache $PACKAGES - -# Add build files -COPY Gopkg.* Makefile $REPO_PATH/ -COPY .git $REPO_PATH/.git -COPY tools $REPO_PATH/tools - -# Intsall go packages -RUN cd $REPO_PATH && make get_tools && make get_vendor_deps - -# Add source files -COPY . $REPO_PATH - -# Build app -RUN cd $REPO_PATH && make all && make install - -# remove packages -RUN apk del $PACKAGES - -# Set default command -CMD ["kavad"] +# Copy app binary over to small container. +# Using alpine instad of scratch to aid in debugging and avoid complicated compile +FROM alpine +COPY --from=builder /go/src/github.com/kava-labs/kava/kvd /go/src/github.com/kava-labs/kava/kvcli /usr/bin/ +CMD ["kvd", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..ae4f1b3b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' +services: + kvd: + image: kava/kava + command: ["kvd", "start"] + ports: + - 46657:46657 + volumes: + - ./.kvd:/root/.kvd + - ./.kvcli:/root/.kvcli + # Avoid printing out all the tendermint logs + logging: + driver: "none" + lcd: + image: kava/kava + command: "kvcli rest-server --chain-id test-kava-1 --node kvd:46657 --laddr tcp://0.0.0.0:1317" + ports: + - 1317:1317 + volumes: + - ./.kvd:/root/.kvd + - ./.kvcli:/root/.kvcli