Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix docker-build command #116

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (ci) [\#117](https://github.com/tharsis/evmos/pull/117) Enable automatic backport of PRs.

## Bug Fixes

* (build) [\#116](https://github.com/tharsis/evmos/pull/116) Fix `build-docker` command

## [v0.3.0] - 2021-11-24

Expand Down
27 changes: 10 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
FROM golang:alpine AS build-env
FROM golang:stretch AS build-env

# Set up dependencies
ENV PACKAGES git build-base

# Set working directory for the build
WORKDIR /go/src/github.com/tharsis/evmos

# Install dependencies
RUN apk add --update $PACKAGES
RUN apk add linux-headers
RUN apt update
RUN apt install git -y

# Add source files
COPY . .

# Make the binary
RUN make build

# Final image
FROM alpine
FROM golang:stretch

RUN apt update
RUN apt install ca-certificates jq -y

# Install ca-certificates
RUN apk add --update ca-certificates jq
WORKDIR /root

# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/tharsis/evmos/build/evmosd /usr/bin/evmosd

# Run evmosd by default
CMD ["evmosd"]
EXPOSE 26656 26657 1317 9090

CMD ["evmosd"]
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ SIMAPP = ./app
HTTPS_GIT := https://github.com/tharsis/evmos.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
NAMESPACE := tharsis
PROJECT := evmos
DOCKER_IMAGE := $(NAMESPACE)/$(PROJECT)
COMMIT_HASH := $(shell git rev-parse --short=10 HEAD)
DOCKER_TAG := $(COMMIT_HASH)

export GO111MODULE = on

Expand Down Expand Up @@ -118,15 +123,15 @@ $(BUILD_TARGETS): go.sum $(BUILDDIR)/
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

docker-build:
build-docker:
# TODO replace with kaniko
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest
# docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:${COMMIT_HASH}
# update old container
docker rm evmos || true
# create a new container from the latest image
docker create --name evmos -t -i tharsis/evmos:latest evmos
docker create --name evmos -t -i ${DOCKER_IMAGE}:latest evmos
# move the binaries to the ./build directory
mkdir -p ./build/
docker cp evmos:/usr/bin/evmosd ./build/
Expand Down
13 changes: 9 additions & 4 deletions docs/quickstart/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ evmosd version
You can build {{ $themeConfig.project.name }} using Docker by running:

```bash
make docker-build
make build-docker
```

This will install the binaries on the `./build` directory. Now, check that the binaries have been
successfully installed:
The command above will create a docker container: `tharsis/evmos:latest`. Now you can run `evmosd` in the container.

```bash
evmosd version
docker run -it -p 26657:26657 -p 26656:26656 -v ~/.evmosd/:/root/.evmosd tharsis/evmos:latest evmosd version

# To initialize
# docker run -it -p 26657:26657 -p 26656:26656 -v ~/.evmosd/:/root/.evmosd tharsis/evmos:latest evmosd init test-chain --chain-id test_9000-2

# To run
# docker run -it -p 26657:26657 -p 26656:26656 -v ~/.evmosd/:/root/.evmosd tharsis/evmos:latest evmosd start
```

### Releases
Expand Down