Skip to content

Commit

Permalink
Remove ko from build process (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyodar authored Apr 16, 2024
1 parent 1cae46f commit ad3659c
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 49 deletions.
46 changes: 7 additions & 39 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ jobs:
include:
- dockerfile: ./indexer/Dockerfile
image: indexer
- dockerfile: ./relayer/Dockerfile
- dockerfile: ./relayer/cmd/Dockerfile
image: relayer
- dockerfile: ./aggregator/cmd/Dockerfile
image: aggregator
- dockerfile: ./operator/cmd/Dockerfile
image: operator
- dockerfile: ./plugin/cmd/Dockerfile
image: operator-plugin
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -66,41 +72,3 @@ jobs:
file: ${{ matrix.dockerfile }}
push: false # dry-run
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}:${{ steps.set_tag.outputs.tag }}

ko:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- path: aggregator/cmd/main.go
image: aggregator
- path: operator/cmd/main.go
image: operator
- path: plugin/cmd/main.go
image: operator-plugin
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit_sha }}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21.x'

- name: Set Tag Name
id: set_tag
run: echo "tag=${{ github.event.inputs.release_tag || github.event.inputs.commit_sha }}" >> $GITHUB_OUTPUT

- name: Set up Ko
uses: ko-build/[email protected]

- name: Build and push container
run: ko build ${{ matrix.path }} --bare --tags=${{ steps.set_tag.outputs.tag }} --push false # dry-run
env:
KO_DOCKER_REPO: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ ___DOCKER___: ##
docker-build-indexer:
docker build -t near-sffl-indexer -f ./indexer/Dockerfile .
docker-build-relayer:
docker build -t near-sffl-test-relayer -f ./relayer/Dockerfile .
docker-build-images: docker-build-indexer docker-build-relayer ## builds and publishes indexer, operator and aggregator docker images
ko build aggregator/cmd/main.go --preserve-import-paths -L
ko build operator/cmd/main.go --preserve-import-paths -L
ko build plugin/cmd/main.go --preserve-import-paths -L
docker build -t near-sffl-test-relayer -f ./relayer/cmd/Dockerfile .
docker-build-aggregator:
docker build -t near-sffl-aggregator -f ./aggregator/cmd/Dockerfile .
docker-build-operator:
docker build -t near-sffl-operator -f ./operator/cmd/Dockerfile .
docker-build-plugin:
docker build -t near-sffl-operator-plugin -f ./plugin/cmd/Dockerfile .
docker-build-images: docker-build-indexer docker-build-relayer docker-build-aggregator docker-build-operator docker-build-plugin ## builds and publishes indexer, operator and aggregator docker images
docker-start-everything: docker-build-images ## starts aggregator and operator docker containers
docker compose up

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ Compose, in which each service is executed in a separate container.
#### Dependencies

In order to build and run the containers, you'll need to install
[Docker](https://www.docker.com/get-started/), as well as
[ko](https://ko.build/install/).
[Docker](https://www.docker.com/get-started/).

You should also have `make` for the build script, or examine and run the same
steps.
Expand Down
18 changes: 18 additions & 0 deletions aggregator/cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.21 AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

WORKDIR /app/aggregator/cmd

RUN go build -v -o /usr/local/bin/aggregator ./...

FROM debian:bookworm

COPY --from=builder /usr/local/bin/aggregator /usr/local/bin/aggregator
ENTRYPOINT ["aggregator"]
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ services:
- near-sffl

aggregator:
image: ko.local/aggregator/cmd/main.go:latest
image: near-sffl-aggregator
container_name: near-sffl-aggregator
depends_on:
mainnet-anvil-setup:
Expand All @@ -267,7 +267,7 @@ services:
- near-sffl

operator0:
image: ko.local/operator/cmd/main.go:latest
image: near-sffl-operator
container_name: near-sffl-operator0
depends_on:
rmq:
Expand Down Expand Up @@ -307,7 +307,7 @@ services:
- near-sffl

operator1:
image: ko.local/operator/cmd/main.go:latest
image: near-sffl-operator
container_name: near-sffl-operator1
depends_on:
operator0-health:
Expand Down
18 changes: 18 additions & 0 deletions operator/cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.21 AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

WORKDIR /app/operator/cmd

RUN go build -v -o /usr/local/bin/operator ./...

FROM debian:bookworm

COPY --from=builder /usr/local/bin/operator /usr/local/bin/operator
ENTRYPOINT ["operator"]
18 changes: 18 additions & 0 deletions plugin/cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.21 AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

WORKDIR /app/plugin/cmd

RUN go build -v -o /usr/local/bin/plugin ./...

FROM debian:bookworm

COPY --from=builder /usr/local/bin/plugin /usr/local/bin/plugin
ENTRYPOINT ["plugin"]
File renamed without changes.

0 comments on commit ad3659c

Please sign in to comment.