Skip to content

Commit 3cdbbf9

Browse files
committed
split api, ui, cli
1 parent fadb9ed commit 3cdbbf9

101 files changed

Lines changed: 10244 additions & 1210 deletions

File tree

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: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,24 @@ 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
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: '20'
37+
- run: cd web && npm install
38+
- run: make build-web
3439
- run: make test-e2e
3540
- run: make test-e2e-contribs
3641

3742
go-test:
3843
name: go-test
3944
runs-on: ubuntu-latest
4045
steps:
41-
- uses: actions/checkout@v3
42-
- uses: actions/setup-go@v3
46+
- uses: actions/checkout@v4
47+
- uses: actions/setup-go@v5
4348
with:
4449
go-version: v1.24.0
4550
- run: make test
@@ -48,8 +53,8 @@ jobs:
4853
name: lint
4954
runs-on: ubuntu-latest
5055
steps:
51-
- uses: actions/checkout@v3
52-
- uses: actions/setup-go@v3
56+
- uses: actions/checkout@v4
57+
- uses: actions/setup-go@v5
5358
with:
5459
go-version: v1.24.0
5560
- run: make lint
@@ -58,8 +63,8 @@ jobs:
5863
name: verify
5964
runs-on: ubuntu-latest
6065
steps:
61-
- uses: actions/checkout@v3
62-
- uses: actions/setup-go@v3
66+
- uses: actions/checkout@v4
67+
- uses: actions/setup-go@v5
6368
with:
6469
go-version: v1.24.0
6570
- 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

.golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ linters:
1515
- errcheck
1616
- errchkjson
1717
- gocritic
18-
- godot
1918
- goprintffuncname
2019
- gosec
2120
- govet

Dockerfile

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

0 commit comments

Comments
 (0)