add docker setup

This commit is contained in:
rhuairahrighairigh 2018-06-21 14:15:00 +01:00
parent bfd726a6e7
commit 666a034608
4 changed files with 49 additions and 33 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
vendor/
Dockerfile
deployment/
*.sublime-project
*.sublime-workspace
.kvd/
.kvcli/

4
.gitignore vendored
View File

@ -17,3 +17,7 @@ vendor
# Exclude text editor files
*.sublime-project
*.sublime-workspace
# Exclude chain data
.kvd/
.kvcli/

View File

@ -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"]

21
docker-compose.yml Normal file
View File

@ -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