Skip to content

Commit

Permalink
Add Docker build (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko authored Jul 22, 2024
1 parent ed4e88c commit 775ce78
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and publish catalyst-api docker images

on:
pull_request:
push:
branches:
- main
- dev
tags:
- "v*"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
docker:
name: Build and publish docker image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.CI_DOCKERHUB_USERNAME }}
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
livepeerci/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=sha
type=ref,event=pr
type=ref,event=tag
type=sha,format=long
type=ref,event=branch
type=semver,pattern={{version}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ github.event.pull_request.head.ref }}
type=raw,value=stable,enable=${{ startsWith(github.event.ref, 'refs/tags/v') }}
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64, linux/arm64
push: true
build-args: |
GIT_VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.event.pull_request.head.sha || github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM golang:1-bullseye as gobuild

ARG TARGETARCH

WORKDIR /src

ADD go.mod go.sum ./
RUN go mod download

ADD . .
RUN make build

ARG GIT_VERSION
ENV GIT_VERSION="${GIT_VERSION}"

FROM ubuntu:22.04 AS catalyst

ENV DEBIAN_FRONTEND=noninteractive

LABEL maintainer="Amritanshu Varshney <[email protected]>"

ARG BUILD_TARGET

RUN apt update && apt install -yqq wget software-properties-common

RUN apt update && apt install -yqq \
curl \
ca-certificates \
procps \
vnstat \
&& rm -rf /var/lib/apt/lists/*

COPY --from=gobuild /src/build/catalyst-api /bin/catalyst-api

CMD ["/bin/catalyst-api"]

0 comments on commit 775ce78

Please sign in to comment.