-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from skip-mev/zygis/add-ci
feat(ci): add automatic Docker builds
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 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,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 |
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,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"] |
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,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} |