Skip to content
Merged
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
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Temporarily Skipped Workflow

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
dummy:
runs-on: ubuntu-latest
steps:
- name: Temporary Pass
run: echo "Workflow skipped for now"

# unit-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.23.x
# - name: Run unit tests
# run: make unit-tests

# checks:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.23.x
# - name: Run checks
# run: make checks

# gosec:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.23.x
# - name: Run gosec
# run: make gosec

# build-image:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.23.x
# - name: Build and push image
# run: |
# make image
# make image-push
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendor/
build/
.env
golang_copyright.txt
shell_copyright.txt
launch.json
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# External Chaincode Builder and Launcher for Kubernetes

This is chaincode builder that uses **Kubernetes bare pods** to build and run [Hyperledger Fabric](https://www.hyperledger.org/use/fabric) chaincode.

The goal is to provide a Kubernetes-native way to handle external builders and launchers for Fabric chaincode deployments.

---

## Features

- Uses Kubernetes bare pods for chaincode build and execution.
- Integrates with the [Fabric Operator](https://github.com/hyperledger-labs/fabric-operator) and the [Fabric Operations Console](https://github.com/hyperledger-labs/fabric-operations-console).
- Simplifies development workflows on Kubernetes without relying on Docker-in-Docker or privileged containers.

---

## Getting Started



### Run the Tests

Once Kubernetes is enabled on Docker Desktop:

```bash
go test ./...
```

---

## Usage with Fabric Operator & Fabric Operations Console

This external builder is compatible with both:

- [Fabric Operator](https://github.com/hyperledger-labs/fabric-operator): Automates lifecycle management of Fabric networks on Kubernetes.
- [Fabric Operations Console](https://github.com/hyperledger-labs/fabric-operations-console): A GUI-based tool to interact with and manage Hyperledger Fabric networks.

You can configure this external chaincode builder within your operator or console deployment for custom chaincode packaging and deployment flows.

---

## License

[Apache 2.0](LICENSE)
1 change: 1 addition & 0 deletions cmd/ibp-builder-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ibp-builder-client
96 changes: 96 additions & 0 deletions cmd/ibp-builder-client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main

import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"time"

"github.com/hyperledger-labs/fabric-chaincode-builder/pkg/command"
"github.com/hyperledger-labs/fabric-chaincode-builder/pkg/logger"

"google.golang.org/grpc"
)

// A Command represents an object that executes an external builder
// command.
type Command interface {
Run(stderr io.Writer, args ...string) (rc int, err error)
}

func main() {
logLevel := os.Getenv("LOGLEVEL")
logger.SetupLogging(logLevel)

log := logger.Logger.Sugar()
log.Info("Log level set to: ", logger.GetLogLevel(logLevel).CapitalString())

var cmd Command

sharedDir := os.Getenv("IBP_BUILDER_SHARED_DIR")
builderEndpoint := os.Getenv("IBP_BUILDER_ENDPOINT")

grpcConn, err := newGRPCClientConn(builderEndpoint)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create connection to %s: %s", builderEndpoint, err)
os.Exit(10)
}
defer grpcConn.Close()

switch filepath.Base(os.Args[0]) {
case "detect":
cmd = &command.Detect{}

case "build":
cmd = &command.Build{
SharedDir: sharedDir,
GRPCClient: grpcConn,
Logger: log,
}

case "release":
cmd = &command.Release{}

case "run":
cmd = &command.Run{
SharedDir: sharedDir,
GRPCClient: grpcConn,
}

default:
fmt.Fprintf(os.Stderr, "Unexpected command: %s", filepath.Base(os.Args[0]))
os.Exit(99)
}

rc, err := cmd.Run(os.Stderr, os.Args[1:]...)
if err != nil {
fmt.Fprintf(os.Stderr, "External builder failed: %s\n", err)
os.Exit(3)
}

os.Exit(rc)
}

func newGRPCClientConn(endpoint string) (*grpc.ClientConn, error) {
timeoutContext, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

return grpc.DialContext(timeoutContext, endpoint, grpc.WithInsecure(), grpc.WithBlock())
}
1 change: 1 addition & 0 deletions cmd/ibp-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ibp-builder
Loading