Skip to content

Commit 5f0cfbe

Browse files
committed
refactor API
1 parent fadb9ed commit 5f0cfbe

44 files changed

Lines changed: 19450 additions & 98 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
name: go-test-e2e
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v3
31-
- uses: actions/setup-go@v3
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-go@v5
3232
with:
3333
go-version: v1.24.0
3434
- run: make test-e2e
@@ -38,8 +38,8 @@ jobs:
3838
name: go-test
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v3
42-
- uses: actions/setup-go@v3
41+
- uses: actions/checkout@v4
42+
- uses: actions/setup-go@v5
4343
with:
4444
go-version: v1.24.0
4545
- run: make test
@@ -48,8 +48,8 @@ jobs:
4848
name: lint
4949
runs-on: ubuntu-latest
5050
steps:
51-
- uses: actions/checkout@v3
52-
- uses: actions/setup-go@v3
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-go@v5
5353
with:
5454
go-version: v1.24.0
5555
- run: make lint
@@ -58,8 +58,8 @@ jobs:
5858
name: verify
5959
runs-on: ubuntu-latest
6060
steps:
61-
- uses: actions/checkout@v3
62-
- uses: actions/setup-go@v3
61+
- uses: actions/checkout@v4
62+
- uses: actions/setup-go@v5
6363
with:
6464
go-version: v1.24.0
6565
- run: make verify

.github/workflows/goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
2323
- uses: actions/setup-go@v5

.github/workflows/image.yaml

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,30 @@ jobs:
1616
image:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-go@v3
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-go@v5
2121
with:
2222
go-version: v1.24.0
2323
check-latest: true
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
cache-dependency-path: web/package-lock.json
31+
2432
# We need this to remove local tags that are not semver so goreleaser doesn't get confused.
2533
- name: Delete non-semver tags
2634
run: 'git tag -d $(git tag -l | grep -v "^v")'
35+
36+
# Set up Docker Buildx for multi-platform builds
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
2740
# If you notice signing errors, you may need to update the cosign version.
2841
- uses: sigstore/cosign-installer@v3.7.0
29-
- name: Install ko
30-
run: go install github.com/google/ko@latest
42+
3143

3244
- name: Install Helm
3345
uses: azure/setup-helm@v3
@@ -37,31 +49,83 @@ jobs:
3749
- name: Set LDFLAGS
3850
run: echo LDFLAGS="$(make ldflags)" | tee -a >> $GITHUB_ENV
3951

40-
# Build ko from HEAD, build and push an image tagged with the commit SHA,
41-
# then keylessly sign it with cosign.
42-
- name: Publish and sign konnector image
52+
# Login to GitHub Container Registry (used by both ko and Docker)
53+
- name: Login to GitHub Container Registry
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
# Build and push konnector image using Dockerfile.konnector
61+
- name: Build and push konnector image
62+
uses: docker/build-push-action@v6
63+
id: build-konnector
64+
with:
65+
context: .
66+
file: ./Dockerfile.konnector
67+
platforms: linux/amd64,linux/arm64
68+
push: true
69+
tags: |
70+
ghcr.io/${{ github.repository_owner }}/konnector:latest
71+
ghcr.io/${{ github.repository_owner }}/konnector:${{ github.sha }}
72+
ghcr.io/${{ github.repository_owner }}/konnector:${{ github.ref_name }}
73+
cache-from: type=gha
74+
cache-to: type=gha,mode=max
75+
build-args: |
76+
LDFLAGS=${{ env.LDFLAGS }}
77+
labels: |
78+
org.opencontainers.image.title=Kube Bind Konnector
79+
org.opencontainers.image.description=Kube Bind konnector component
80+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
81+
org.opencontainers.image.revision=${{ github.sha }}
82+
org.opencontainers.image.version=${{ github.ref_name }}
83+
84+
# Sign the konnector image
85+
- name: Sign konnector image
4386
env:
44-
KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/konnector
4587
COSIGN_EXPERIMENTAL: 'true'
4688
run: |
47-
echo "${{ github.token }}" | ko login ghcr.io --username "${{ github.actor }}" --password-stdin
48-
img=$(ko build --bare --platform=all -t latest -t ${{ github.sha }} -t ${{github.ref_name}} ./cmd/konnector)
49-
echo "built ${img}"
89+
img="ghcr.io/${{ github.repository_owner }}/konnector@${{ steps.build-konnector.outputs.digest }}"
90+
echo "signing ${img}"
5091
cosign sign ${img} \
5192
--yes \
5293
-a sha=${{ github.sha }} \
5394
-a ref=${{ github.ref }} \
5495
-a run_id=${{ github.run_id }} \
5596
-a run_attempt=${{ github.run_attempt }}
5697
57-
- name: Publish and sign backend image
98+
# Build and push backend image using Dockerfile (includes frontend)
99+
- name: Build and push backend image
100+
uses: docker/build-push-action@v6
101+
id: build
102+
with:
103+
context: .
104+
file: ./Dockerfile
105+
platforms: linux/amd64,linux/arm64
106+
push: true
107+
tags: |
108+
ghcr.io/${{ github.repository_owner }}/backend:latest
109+
ghcr.io/${{ github.repository_owner }}/backend:${{ github.sha }}
110+
ghcr.io/${{ github.repository_owner }}/backend:${{ github.ref_name }}
111+
cache-from: type=gha
112+
cache-to: type=gha,mode=max
113+
build-args: |
114+
LDFLAGS=${{ env.LDFLAGS }}
115+
labels: |
116+
org.opencontainers.image.title=Kube Bind Backend
117+
org.opencontainers.image.description=Kube Bind backend with integrated Vue.js frontend
118+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
119+
org.opencontainers.image.revision=${{ github.sha }}
120+
org.opencontainers.image.version=${{ github.ref_name }}
121+
122+
# Sign the backend image
123+
- name: Sign backend image
58124
env:
59-
KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/backend
60125
COSIGN_EXPERIMENTAL: 'true'
61126
run: |
62-
echo "${{ github.token }}" | ko login ghcr.io --username "${{ github.actor }}" --password-stdin
63-
img=$(ko build --bare --platform=all -t latest -t ${{ github.sha }} -t ${{github.ref_name}} ./cmd/backend)
64-
echo "built ${img}"
127+
img="ghcr.io/${{ github.repository_owner }}/backend@${{ steps.build.outputs.digest }}"
128+
echo "signing ${img}"
65129
cosign sign ${img} \
66130
--yes \
67131
-a sha=${{ github.sha }} \

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ coverage.*
1515
/bin
1616
docs/generators/cli-doc/cli-doc
1717
apiserviceexport.yaml
18-
*.prod
18+
*.prod
19+
20+
# Frontend dependencies and build
21+
web/node_modules/
22+
web/dist/
23+
web/.vite/
24+
web/*.tsbuildinfo

Dockerfile

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,64 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.24.0 AS builder
15+
FROM golang:1.24.0 AS go-build-env
16+
WORKDIR /app
17+
18+
# Accept build arguments for multi-arch support
19+
ARG TARGETARCH
20+
ARG TARGETOS
21+
ARG LDFLAGS
22+
23+
RUN apt-get update && apt-get install -y make jq
24+
25+
# <- COPY go.mod and go.sum files to the workspace
26+
COPY go.mod .
27+
COPY go.sum .
28+
29+
# COPY the source code as the last step
30+
COPY . .
31+
32+
# Build with custom LDFLAGS if provided, otherwise use make build
33+
# Use TARGETOS and TARGETARCH for cross-compilation
34+
RUN if [ -n "$LDFLAGS" ]; then \
35+
echo "Building with LDFLAGS: $LDFLAGS for $TARGETOS/$TARGETARCH"; \
36+
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="$LDFLAGS" -o bin/backend ./cmd/backend; \
37+
else \
38+
GOOS=$TARGETOS GOARCH=$TARGETARCH make build; \
39+
fi
40+
41+
# Use node:lts-alpine for better compatibility and smaller size
42+
FROM node:20.18.0-alpine3.20 AS ui-build-env
43+
WORKDIR /app
44+
45+
# Install build dependencies needed for native modules
46+
RUN apk add --no-cache python3 make g++
47+
48+
# Copy package files
49+
COPY ./web/package*.json ./
50+
COPY ./web/.npmrc ./
51+
52+
RUN npm install
53+
54+
# Install dependencies with specific flags to handle optional deps and architecture issues
55+
RUN npm ci --prefer-offline --no-audit --no-fund --no-optional
56+
57+
# Copy the Vue app files
58+
COPY ./web .
59+
60+
# Set environment to avoid native dependency issues
61+
ENV NODE_ENV=production
62+
ENV VITE_BUILD_TARGET=docker
63+
64+
# Building UI with Docker-specific config
65+
RUN npm run build
66+
67+
FROM alpine:3.22.1
68+
RUN apk --update add ca-certificates
69+
70+
COPY --from=go-build-env /app/bin/backend /bin
71+
COPY --from=ui-build-env /app/dist /www
72+
73+
74+
75+
ENTRYPOINT ["/bin/backend"]

Dockerfile.konnector

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2022 The Kube Bind Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM golang:1.24.0 AS builder
16+
WORKDIR /app
17+
18+
# Accept build arguments for multi-arch support
19+
ARG TARGETARCH
20+
ARG TARGETOS
21+
ARG LDFLAGS
22+
23+
# Copy the source code (needed for local replacements in go.mod)
24+
COPY . .
25+
RUN go mod download
26+
27+
# Build the konnector binary
28+
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="$LDFLAGS" -o bin/konnector ./cmd/konnector
29+
30+
FROM alpine:3.22.1
31+
RUN apk --update add ca-certificates
32+
33+
COPY --from=builder /app/bin/konnector /bin/konnector
34+
35+
ENTRYPOINT ["/bin/konnector"]

Makefile

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -376,28 +376,38 @@ deploy-docs: venv ## Deploy docs
376376
REMOTE=$(REMOTE) BRANCH=$(BRANCH) docs/scripts/deploy-docs.sh
377377

378378
# Example: make IMAGE_REPO=ghcr.io/<username> image-local
379+
# Set PLATFORMS to override default architectures (e.g., make PLATFORMS=linux/amd64,linux/arm64 image-local)
380+
# For local builds, default to current architecture on Linux platform to support --load
381+
PLATFORMS ?= linux/$(ARCH)
379382
.PHONY: image-local
380383
image-local:
381-
@echo "Building images locally with tag $(REV)"
382-
@command -v ko >/dev/null 2>&1 || { echo "ko not found. Install with: go install github.com/google/ko@latest"; exit 1; }
383-
384-
@echo "Building konnector image locally..."
385-
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
386-
--local \
387-
-B \
388-
-t $(REV) \
389-
./cmd/konnector
390-
391-
@echo "Building backend image locally..."
392-
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
393-
--local \
394-
-B \
395-
-t $(REV) \
396-
./cmd/backend
397-
398-
@echo "Successfully built local images:"
399-
@echo " $(IMAGE_REPO)/konnector:$(REV)"
400-
@echo " $(IMAGE_REPO)/backend:$(REV)"
384+
@echo "Building multi-arch images locally with tag $(REV) for platforms: $(PLATFORMS)"
385+
@command -v docker >/dev/null 2>&1 || { echo "docker not found. Please install Docker"; exit 1; }
386+
@docker buildx version >/dev/null 2>&1 || { echo "docker buildx not found. Please enable buildx in Docker"; exit 1; }
387+
388+
@# Create buildx builder if it doesn't exist
389+
@docker buildx create --name kube-bind-builder --use 2>/dev/null || docker buildx use kube-bind-builder 2>/dev/null || true
390+
@docker buildx inspect --bootstrap >/dev/null 2>&1
391+
392+
@echo "Building konnector multi-arch image locally..."
393+
docker buildx build \
394+
--platform $(PLATFORMS) \
395+
--build-arg LDFLAGS="$(LDFLAGS)" \
396+
-t $(IMAGE_REPO)/konnector:$(REV) \
397+
-f Dockerfile.konnector \
398+
--load .
399+
400+
@echo "Building backend multi-arch image locally..."
401+
docker buildx build \
402+
--platform $(PLATFORMS) \
403+
--build-arg LDFLAGS="$(LDFLAGS)" \
404+
-t $(IMAGE_REPO)/backend:$(REV) \
405+
-f Dockerfile \
406+
--load .
407+
408+
@echo "Successfully built multi-arch local images:"
409+
@echo " $(IMAGE_REPO)/konnector:$(REV) ($(PLATFORMS))"
410+
@echo " $(IMAGE_REPO)/backend:$(REV) ($(PLATFORMS))"
401411

402412
.PHONY: kind-load
403413
kind-load:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ There are several ways to communicate with us:
5858

5959
All the actions shown between the clusters are done by the konnector, except: the pull at the start is done by the kubectl plugin that installs the konnector.
6060

61+
See [web/README.md](./web/README.md) for detailed frontend documentation.
62+
6163
## Usage
6264

6365
To get familiar with setting up the environment, please check out docs at [kube-bind.io](https://docs.kube-bind.io/main/setup).

0 commit comments

Comments
 (0)