Skip to content

Commit

Permalink
Publish Docker images to Docker Hub on merge to main (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti authored Jun 19, 2024
1 parent 1f8bb9a commit 42315d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.DUNE_ENG_ACCESS_TOKEN }}
ECR_REGISTRY: public.ecr.aws/duneanalytics
ECR_REPOSITORY: node-indexer
DOCKER_HUB_KEY: ${{ secrets.DOCKER_HUB_KEY }}
run: |
make image-build
make image-push
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.22-alpine AS builder

# dependencies to build the project & dependencies
RUN apk add --no-cache git make curl gcc musl-dev binutils-gold
RUN apk add --no-cache git make curl gcc musl-dev binutils-gold bash

# First copy just enough to pull all dependencies, to cache this layer
COPY go.mod go.sum Makefile /app/
Expand All @@ -11,8 +11,7 @@ RUN make setup
# Copy the rest of the source code
COPY . .

# Lint, build, etc..
RUN make test
# Build
RUN make build

# Stage 2: Create a minimal runtime image
Expand Down
27 changes: 10 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.PHONY: all setup lint build test image-build image-push

GITHUB_SHA ?= HEAD
REF_TAG := $(shell echo ${GITHUB_REF_NAME} | tr -cd '[:alnum:]')
IMAGE_TAG := ${ECR_REGISTRY}/${ECR_REPOSITORY}:${REF_TAG}-$(shell git rev-parse --short "${GITHUB_SHA}")-${GITHUB_RUN_NUMBER}
TEST_TIMEOUT := 10s
SHELL := /bin/bash

all: lint test build

Expand Down Expand Up @@ -38,18 +36,13 @@ gen-mocks: bin/moq ./client/jsonrpc/ ./client/duneapi/
./bin/moq -pkg jsonrpc_mock -out ./mocks/jsonrpc/rpcnode.go ./client/jsonrpc BlockchainClient
./bin/moq -pkg duneapi_mock -out ./mocks/duneapi/client.go ./client/duneapi BlockchainIngester


image-build:
@echo "# Building indexer docker image for amd64 and arm64"
docker buildx build --platform linux/amd64 -t ${IMAGE_TAG}-amd64 -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} .
docker buildx build --platform linux/arm64 -t ${IMAGE_TAG}-arm64 -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} .

image-push: image-build
@echo "# Pushing indexer docker images"
# docker manifest create --insecure "${IMAGE_TAG}" "${IMAGE_TAG}-amd64"
# docker manifest create -a "${IMAGE_TAG}" "${IMAGE_TAG}-arm64" --insecure
# docker manifest push "${IMAGE_TAG}" --insecure
# docker push "${IMAGE_TAG}-amd64"
# docker push "${IMAGE_TAG}-arm64"
# docker rmi "${IMAGE_TAG}-amd64"
# docker rmi "${IMAGE_TAG}-arm64"
@echo "# Building Docker images"
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t duneanalytics/node-indexer:latest -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} .

image-push:
@echo "# Pushing Docker images to Docker Hub (after building)"
echo -n "${DOCKER_HUB_KEY}" | docker login --username duneanalytics --password-stdin
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t duneanalytics/node-indexer:latest -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} --push .

0 comments on commit 42315d3

Please sign in to comment.