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

Update docker.yml and Dockerfile, fix ci #466

Closed
wants to merge 7 commits into from
Closed
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
64 changes: 25 additions & 39 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build & Push
# Build & Push rebuilds the iavl docker image on every push to master and creation of tags
# and pushes the image to https://hub.docker.com/r/interchainio/iavl/tags
# and pushes the image to https://ghcr.io/cosmos/iavl

on:
pull_request:
push:
Expand All @@ -11,45 +12,30 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5

jobs:
build:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
go-version: "^1.17.6"
- uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=interchainio/iavl
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}"
fi
echo ::set-output name=tags::${TAGS}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1.6.0

- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1.14.1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2.10.0
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/iavl:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this!! we should migrate everything we have to this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, ok-- this is a package deal with the above docker image, at least in my experience the multiarch stuff. Let me see what I can do.

26 changes: 5 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
FROM golang:1.14 as build
# This docker image is designed to be used in CI for benchmarks and also by developers wanting
# an environment that always has the lastest rocksdb and cleveldb.

WORKDIR /iavl
FROM faddat/archlinux

ARG GOFLAGS=""
ENV GOFLAGS=$GOFLAGS
ENV GO111MODULE=on
RUN pacman -Syyu --noconfirm leveldb rocksdb go base-devel git

# Download dependencies first - this should be cacheable.
COPY go.mod go.sum ./
RUN go mod download

# Now add the local iavl repo, which typically isn't cacheable.
COPY . .

# Build the server.
RUN go get ./cmd/iavlserver

# Make a minimal image.
FROM gcr.io/distroless/base

COPY --from=build /go/bin/iavlserver /

EXPOSE 8090 8091
ENTRYPOINT ["/iavlserver"]
CMD ["-db-name", "iavl", "-datadir", "."]
RUN go install -tags cleveldb,rocksdb,badgerdb cmd/...