Skip to content
Open
Show file tree
Hide file tree
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
229 changes: 49 additions & 180 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: docker-build-and-push
on:
push:
branches:
- '*'
- "*"
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

jobs:
docker-build-amd64:
runs-on: ubuntu-latest
docker-multiarch-build:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,86 +25,46 @@ jobs:
username: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}
password: ${{ secrets.CUSTOM_DOCKERHUB_TOKEN }}

# Устанавливаем buildx + общий builder
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Create sanitized branch name
id: sanitize
run: echo "branch=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')" >> $GITHUB_OUTPUT

- name: Build and push goose
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.goose
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/amd64

- name: Build and push apiserver
uses: docker/build-push-action@v6
install: true
driver-opts: |
image=moby/buildkit:latest
network=host

# Кэшируем слои для повторных сборок
- name: Configure Buildx cache
uses: actions/cache@v4
with:
context: .
file: ./Dockerfile.apiserver
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/amd64

- name: Build and push backend
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.backend
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/amd64

- name: Build and push webhook
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.webhook
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/amd64

docker-build-arm64:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 8

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}
password: ${{ secrets.CUSTOM_DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Create sanitized branch name
id: sanitize
run: echo "branch=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')" >> $GITHUB_OUTPUT

# Устанавливаем QEMU для эмуляции amd64/arm64
- name: Enable QEMU emulation
run: docker run --rm --privileged tonistiigi/binfmt --install all

# --- BUILD AND PUSH ---

- name: Build and push goose
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.goose
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/arm64
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Build and push apiserver
uses: docker/build-push-action@v6
Expand All @@ -113,8 +73,11 @@ jobs:
file: ./Dockerfile.apiserver
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/arm64
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Build and push backend
uses: docker/build-push-action@v6
Expand All @@ -123,8 +86,11 @@ jobs:
file: ./Dockerfile.backend
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/arm64
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Build and push webhook
uses: docker/build-push-action@v6
Expand All @@ -133,112 +99,15 @@ jobs:
file: ./Dockerfile.webhook
push: true
provenance: false
tags: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/arm64

docker-multiarch-push:
runs-on: self-hosted
needs:
- docker-build-arm64
- docker-build-amd64
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 8

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}
password: ${{ secrets.CUSTOM_DOCKERHUB_TOKEN }}

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

- name: Create sanitized branch name
id: sanitize
run: echo "branch=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')" >> $GITHUB_OUTPUT

- name: Create and push multi-arch goose
run: |
docker manifest create \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch amd64

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch arm64

docker manifest push \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-goose:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

- name: Create and push multi-arch apiserver
run: |
docker manifest create \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch amd64

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch arm64

docker manifest push \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-apiserver:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

- name: Create and push multi-arch backend
run: |
docker manifest create \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch amd64

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch arm64

docker manifest push \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-backend:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Create and push multi-arch webhook
# Обновляем кэш после сборок
- name: Move new cache
if: always()
run: |
docker manifest create \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:amd64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch amd64

docker manifest annotate \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:arm64-${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }} \
--arch arm64

docker manifest push \
${{ secrets.CUSTOM_DOCKERHUB_USERNAME }}/sgroups.k8s.netguard-webhook:${{ steps.sanitize.outputs.branch }}-${{ steps.short-sha.outputs.sha }}
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
10 changes: 8 additions & 2 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"context"
"log"
"flag"
"log"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -121,7 +121,7 @@ func main() {

// Setup gRPC server
grpcServer := grpc.NewServer()
netguardServer := netguard.NewNetguardServiceServer(netguardFacade)
netguardServer := netguard.NewServiceServer(netguardFacade)
netguardpb.RegisterNetguardServiceServer(grpcServer, netguardServer)

// Register gRPC health check service
Expand Down Expand Up @@ -226,6 +226,12 @@ func setupSyncManager(ctx context.Context, cfg *config.Config) interfaces.SyncMa
return nil
}

// Register Service syncer
serviceSyncer := syncers.NewServiceSyncer(sgroupsClient, logger)
if err := syncManager.RegisterSyncer(types.SyncSubjectTypeServices, serviceSyncer); err != nil {
return nil
}

// Start sync manager
if err := syncManager.Start(ctx); err != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
cel.dev/expr v0.23.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/PRO-Robotech/protos v1.0.0-dev.8
github.com/PRO-Robotech/protos v1.0.1-dev.6
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/H-BF/corlib v0.0.12 h1:bXalNq4Bxz5EboVS+ho4oIqGk3tpJ3PlkLwMBuYJyts=
github.com/H-BF/corlib v0.0.12/go.mod h1:xdSRxnzZf9tF8K8uy3EOi9N7JylDik0fvRwdK3uHzl4=
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/PRO-Robotech/protos v1.0.0-dev.8 h1:5AmaePw11q52Y1IQ8HtKI65GDN1y5icerP2v1RGYusQ=
github.com/PRO-Robotech/protos v1.0.0-dev.8/go.mod h1:TfXCt4ZxBl9Lc9HjzQumkSuECYFGsCuwlnX3ZkqLV30=
github.com/PRO-Robotech/protos v1.0.1-dev.6 h1:UUaINowhhOGnV6YEAsYxiKfbCKUwrRKEsTKNc2JlJGo=
github.com/PRO-Robotech/protos v1.0.1-dev.6/go.mod h1:TfXCt4ZxBl9Lc9HjzQumkSuECYFGsCuwlnX3ZkqLV30=
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
Loading
Loading