-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and push Docker image on commit to main
- Loading branch information
Showing
4 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: "Build" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: "Build Docker image and push to Dockerhub" | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_REGION: eu-west-1 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# - name: Configure AWS Credentials | ||
# uses: aws-actions/[email protected] | ||
# with: | ||
# role-to-assume: arn:aws:iam::118330671040:role/duneapi-ci | ||
# aws-region: ${{ env.AWS_REGION }} | ||
|
||
# - name: Login to Amazon ECR | ||
# id: login-ecr | ||
# uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- env: | ||
GITHUB_TOKEN: ${{ secrets.DUNE_ENG_ACCESS_TOKEN }} | ||
ECR_REGISTRY: public.ecr.aws/duneanalytics | ||
ECR_REPOSITORY: blockchain-ingester | ||
run: | | ||
make image-build | ||
make image-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM golang:1.22-bookworm AS builder | ||
|
||
RUN apt update && apt install -y curl make | ||
|
||
ARG GITHUB_TOKEN | ||
|
||
# first copy just enough to pull all dependencies, to cache this layer | ||
COPY go.mod go.sum Makefile /app/ | ||
WORKDIR /app/ | ||
RUN git config --global url."https://dune-eng:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com" \ | ||
&& make setup | ||
|
||
# lint, build, etc.. | ||
COPY . /app/ | ||
RUN make build | ||
|
||
FROM debian:bookworm-slim | ||
RUN apt update \ | ||
&& apt install -y ca-certificates \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /app/ingester /app/ | ||
ENTRYPOINT ["/app/ingester"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
.PHONY: all setup lint harvester test image-build image-push | ||
.PHONY: all setup lint build test image-build image-push | ||
|
||
APPLICATION := harvester | ||
APPLICATION := ingester | ||
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 | ||
|
||
all: lint test harvester | ||
all: lint test build | ||
|
||
setup: bin/golangci-lint bin/gofumpt | ||
go mod download | ||
|
@@ -16,8 +16,8 @@ bin/golangci-lint: | |
bin/gofumpt: bin | ||
GOBIN=$(PWD)/bin go install mvdan.cc/[email protected] | ||
|
||
harvester: lint cmd/main.go | ||
go build -o harvester cmd/main.go | ||
build: lint cmd/main.go | ||
go build -o ingester cmd/main.go | ||
|
||
lint: bin/golangci-lint bin/gofumpt | ||
go fmt ./... | ||
|
@@ -31,11 +31,11 @@ test: | |
go test -timeout=$(TEST_TIMEOUT) -race -bench=. -benchmem -cover ./... | ||
|
||
image-build: | ||
@echo "# Building harvester docker image..." | ||
@echo "# Building ingester docker image..." | ||
docker build -t $(APPLICATION) -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} . | ||
|
||
image-push: image-build | ||
@echo "# Pushing harvester docker image..." | ||
@echo "# Pushing ingester docker image..." | ||
docker tag $(APPLICATION) ${IMAGE_TAG} | ||
docker push ${IMAGE_TAG} | ||
# docker push ${IMAGE_TAG} | ||
docker rmi ${IMAGE_TAG} |