Skip to content

Commit

Permalink
Merge pull request #26 from skip-mev/zygis/add-ci
Browse files Browse the repository at this point in the history
feat(ci): add automatic Docker builds
  • Loading branch information
Zygimantass committed Apr 20, 2023
2 parents 10ae188 + 654d331 commit e8646d5
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build skipper-go

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the Docker image
run: make GITHUB_TAG=${{ inputs.tag }} GITHUB_ACTIONS=true build-docker
working-directory: skipper-go
19 changes: 19 additions & 0 deletions skipper-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ghcr.io/oshied/base-go1.20:bionic AS BUILD
WORKDIR /app

COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY . ./

RUN make build

FROM gcr.io/distroless/base-debian11:debug

WORKDIR /usr/local/bin

COPY --from=BUILD /app/backrunner /usr/local/bin/backrunner

# you must add to ENTRYPOINT "--config=</path/to/skipper-go/config>", "--multihop=<YOUR CONTRACT ADDRESS HERE>", "--key=<YOUR PRIVATE KEY HERE>"
ENTRYPOINT ["/usr/local/bin/backrunner", "start"]
45 changes: 45 additions & 0 deletions skipper-go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
BINARY_NAME=backrunner
PLATFORM=linux/amd64
REGION=us-east-2
ENVIRONMENT=mainnet

SHELL := /bin/bash

COMMIT:=$(shell git rev-parse --short HEAD)
TAG=$(COMMIT)
REGISTRY=ghcr.io
REPO=skip-mev/skipper-go
IMAGE=$(REGISTRY)/$(REPO):$(TAG)
NOMAD_FILE:=nomad/skipper-go-evmos.nomad
LEVANT_VAR_FILE:=$(shell mktemp -d)/levant.yaml

ifneq ($(GITHUB_TAG),)
TAG=$(GITHUB_TAG)
endif

ifdef GITHUB_ACTIONS
GITHUB_ACTIONS_FLAGS = --cache-to type=gha --cache-from type=gha
endif


build:
go mod tidy
go build -o ${BINARY_NAME} main.go


build-docker:
docker buildx build \
--platform ${PLATFORM} \
-t ${IMAGE} \
-t ${REGISTRY}/${REPO}:latest \
-t ${REGISTRY}/${REPO}:${COMMIT} \
--push \
${GITHUB_ACTIONS_FLAGS} \
-f Dockerfile \
.

deploy:
touch ${LEVANT_VAR_FILE}
yq e -i '.env |= "${ENVIRONMENT}"' ${LEVANT_VAR_FILE}
yq e -i '.image |= "${IMAGE}"' ${LEVANT_VAR_FILE}
levant deploy -force-count -var-file=${LEVANT_VAR_FILE} ${NOMAD_FILE}

0 comments on commit e8646d5

Please sign in to comment.