Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] custom docker image for private registry #3

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions .github/workflows/custom-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build and Push

on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
# build-binaries:
# name: Build binaries
# runs-on: ubuntu-latest
# env: { CGO_ENABLED: 0 }
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Setup Go
# uses: actions/setup-go@v4
# with: { go-version: '1.21' }

# - name: Build go2rtc_win64
# env: { GOOS: windows, GOARCH: amd64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_win64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_win64, path: go2rtc.exe }

# - name: Build go2rtc_win32
# env: { GOOS: windows, GOARCH: 386 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_win32
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_win32, path: go2rtc.exe }

# - name: Build go2rtc_win_arm64
# env: { GOOS: windows, GOARCH: arm64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_win_arm64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_win_arm64, path: go2rtc.exe }

# - name: Build go2rtc_linux_amd64
# env: { GOOS: linux, GOARCH: amd64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_amd64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_amd64, path: go2rtc }

# - name: Build go2rtc_linux_i386
# env: { GOOS: linux, GOARCH: 386 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_i386
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_i386, path: go2rtc }

# - name: Build go2rtc_linux_arm64
# env: { GOOS: linux, GOARCH: arm64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_arm64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_arm64, path: go2rtc }

# - name: Build go2rtc_linux_arm
# env: { GOOS: linux, GOARCH: arm, GOARM: 7 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_arm
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_arm, path: go2rtc }

# - name: Build go2rtc_linux_armv6
# env: { GOOS: linux, GOARCH: arm, GOARM: 6 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_armv6
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_armv6, path: go2rtc }

# - name: Build go2rtc_linux_mipsel
# env: { GOOS: linux, GOARCH: mipsle }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_linux_mipsel
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_linux_mipsel, path: go2rtc }

# - name: Build go2rtc_mac_amd64
# env: { GOOS: darwin, GOARCH: amd64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_mac_amd64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_mac_amd64, path: go2rtc }

# - name: Build go2rtc_mac_arm64
# env: { GOOS: darwin, GOARCH: arm64 }
# run: go build -ldflags "-s -w" -trimpath
# - name: Upload go2rtc_mac_arm64
# uses: actions/upload-artifact@v3
# with: { name: go2rtc_mac_arm64, path: go2rtc }

docker-image:
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.PRIVATE_REGISTRY_HOST }}/services/go2rtc
tags: |
type=ref,event=branch
type=semver,pattern={{version}},enable=false
type=match,pattern=v(.*),group=1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to Private Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY_HOST }}
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: |
linux/amd64
linux/386
linux/arm/v7
linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

docker-hardware:
name: Build docker hardware
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta-hw
uses: docker/metadata-action@v4
with:
images: ${{ secrets.PRIVATE_REGISTRY_HOST }}/services/go2rtc
flavor: |
suffix=-hardware
latest=false
tags: |
type=ref,event=branch
type=semver,pattern={{version}},enable=false
type=match,pattern=v(.*),group=1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to Private Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY_HOST }}
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: hardware.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-hw.outputs.tags }}
labels: ${{ steps.meta-hw.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max