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 4 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@v2
-
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.15.4"
- uses: actions/checkout@v2.4.0
- 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.12.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2.7.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.

22 changes: 4 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
FROM golang:1.14 as build

WORKDIR /iavl
# 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.
FROM faddat/archlinux
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about using one of the official arch or alpine linux distros?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ping

Copy link
Contributor Author

@faddat faddat Apr 11, 2022

Choose a reason for hiding this comment

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

hey sure thing, but ah, that means alpine and thus musl.

I maintain that image because Arch isn't multiarch by default. If we then search for distros with really rigorously up to date rolling release package management, we come up emptdy. What do you think?

That image is built here:

https://github.com/faddat/archlinux-docker/runs/5964553569?check_suite_focus=true

Here's how it works:

it makes amd64
it makes arm64

it combines them into the same manifest and then pushes to docker hub daily.

Since few use musl for real, using alpine as build distro invites pain in the form of build environments that don't match runtime environments.

If popularity / adoption / usage matters, I do think it is the leading multiarch arch linux image on docker hub.

image


ARG GOFLAGS=""
ENV GOFLAGS=$GOFLAGS
ENV GO111MODULE=on

# Download dependencies first - this should be cacheable.
COPY go.mod go.sum ./
RUN go mod download
RUN pacman -Syyu --noconfirm leveldb rocksdb go base-devel

# 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/...