Skip to content

Commit

Permalink
Introduce LOOP plugin support for devspace goreleaser builds
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryNguyen5 committed Mar 11, 2024
1 parent a2db9de commit e76836f
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .goreleaser.develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dockers:
goarch: amd64
extra_files:
- tmp/linux_amd64/libs
- tmp/linux_amd64/plugins
- tools/bin/ldd_fix
build_flag_templates:
- "--platform=linux/amd64"
Expand All @@ -86,6 +87,7 @@ dockers:
goarch: arm64
extra_files:
- tmp/linux_arm64/libs
- tmp/linux_arm64/plugins
- tools/bin/ldd_fix
build_flag_templates:
- "--platform=linux/arm64"
Expand All @@ -109,6 +111,7 @@ dockers:
goarch: amd64
extra_files:
- tmp/linux_amd64/libs
- tmp/linux_amd64/plugins
- tools/bin/ldd_fix
build_flag_templates:
- "--platform=linux/amd64"
Expand All @@ -133,6 +136,7 @@ dockers:
goarch: arm64
extra_files:
- tmp/linux_arm64/libs
- tmp/linux_arm64/plugins
- tools/bin/ldd_fix
build_flag_templates:
- "--platform=linux/arm64"
Expand Down
5 changes: 5 additions & 0 deletions .goreleaser.devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ dockers:
goarch: amd64
extra_files:
- tmp/linux_amd64/libs
- tmp/linux_amd64/plugins
- tools/bin/ldd_fix
build_flag_templates:
- "--platform=linux/amd64"
- "--pull"
- "--build-arg=CHAINLINK_USER=chainlink"
- "--build-arg=COMMIT_SHA={{ .FullCommit }}"
- "--build-arg=CL_MEDIAN_CMD=chainlink-feeds"
- "--build-arg=CL_MERCURY_CMD=chainlink-mercury"
- "--build-arg=CL_SOLANA_CMD=chainlink-solana"
- "--build-arg=CL_STARKNET_CMD=chainlink-starknet"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.description={{ .Env.IMAGE_LABEL_DESCRIPTION }}"
- "--label=org.opencontainers.image.licenses={{ .Env.IMAGE_LABEL_LICENSES }}"
Expand Down
2 changes: 1 addition & 1 deletion charts/chainlink-cluster/templates/chainlink-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ data:
{{ else }}
{{ end }}
---
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions core/chainlink.goreleaser.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& rm -rf /var/lib/apt/lists/*

COPY ./chainlink /usr/local/bin/

# Copy native libs if cgo is enabled
COPY ./tmp/linux_${TARGETARCH}/libs /usr/local/bin/libs

# Copy plugins and enable them
COPY ./tmp/linux_${TARGETARCH}/plugins/* /usr/local/bin/
# Allow individual plugins to be enabled by supplying their path
ARG CL_MEDIAN_CMD
ARG CL_MERCURY_CMD
ARG CL_SOLANA_CMD
ARG CL_STARKNET_CMD
ENV CL_MEDIAN_CMD=${CL_MEDIAN_CMD} \
CL_MERCURY_CMD=${CL_MERCURY_CMD} \
CL_SOLANA_CMD=${CL_SOLANA_CMD} \
CL_STARKNET_CMD=${CL_STARKNET_CMD}
# Temp fix to patch correctly link the libwasmvm.so
COPY ./tools/bin/ldd_fix /usr/local/bin/ldd_fix
RUN chmod +x /usr/local/bin/ldd_fix
Expand Down
65 changes: 62 additions & 3 deletions tools/bin/goreleaser_utils
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -x


# get machine / kernel name
_get_platform() {
Expand Down Expand Up @@ -58,19 +60,76 @@ before_hook() {
cp -f "$wasmvm_lib_path_darwin_amd64" "$lib_path/darwin_amd64/libs"
mkdir -p "$lib_path/darwin_arm64/libs"
cp -f "$wasmvm_lib_path_darwin_arm64" "$lib_path/darwin_arm64/libs"

# MOVE PLUGINS HERE
gobin=$(go env GOPATH)/bin

install_local_plugins "linux" "amd64" "$gobin"/linux_amd64
install_remote_plugins "linux" "amd64" "$gobin"/linux_amd64
mkdir -p "$lib_path/linux_amd64/plugins"
cp "$gobin"/linux_amd64/chainlink* "$lib_path/linux_amd64/plugins"

install_local_plugins "linux" "arm64" "$gobin"/linux_arm64
install_remote_plugins "linux" "arm64" "$gobin"/linux_arm64
mkdir -p "$lib_path/linux_arm64/plugins"
cp "$gobin"/linux_arm64/chainlink* "$lib_path/linux_arm64/plugins"
}

install_local_plugins() {
local -r goos=$1
local -r goarch=$2
local -r gobin=$3

GOBIN=$gobin GOARCH=$goarch GOOS=$goos make install-medianpoc
GOBIN=$gobin GOARCH=$goarch GOOS=$goos make install-install-ocr3-capability
}

get_remote_plugin_paths() {
plugins=(
"github.com/smartcontractkit/chainlink-solana|/pkg/solana/cmd/chainlink-solana"
"github.com/smartcontractkit/chainlink-starknet/relayer|/pkg/chainlink/cmd/chainlink-starknet"
"github.com/smartcontractkit/chainlink-feeds|/cmd/chainlink-feeds"
"github.com/smartcontractkit/chainlink-data-streams|/mercury/cmd/chainlink-mercury"
)

for plugin in "${plugins[@]}"; do
plugin_dep_name=$(echo "$plugin" | cut -d"|" -f1)
plugin_main=$(echo "$plugin" | cut -d"|" -f2)

full_plugin_path=$(go list -m -f "{{.Dir}}" "$plugin_dep_name")"$plugin_main"
echo "$full_plugin_path"
done
}

install_remote_plugins() {
local -r goos=$1
local -r goarch=$2
local -r gobin=$(go env GOPATH)/bin

for plugin in $(get_remote_plugin_paths); do
GOBIN=$gobin GOARCH=$goarch GOOS=$goos go install "$plugin"
done

}

# binary build post hook
# moves native libraries to binary libs directory
build_post_hook() {
local -r dist_path=$1
local -r lib_path=$dist_path/libs
local -r lib_dest_path=$dist_path/libs
local -r platform=$2
local -r arch=$3
local -r plugin_src_path=./tmp/${platform}_${arch}/plugins
local -r plugin_dest_path=$dist_path/plugins

# COPY NATIVE LIBRARIES HERE
local -r wasmvm_lib_path=$(_get_wasmvm_lib_path "$platform" "$arch")
mkdir -p "$lib_path"
cp "$wasmvm_lib_path" "$lib_path"
mkdir -p "$lib_dest_path"
cp "$wasmvm_lib_path" "$lib_dest_path"

# COPY PLUGINS HERE
mkdir -p "$plugin_dest_path"
cp -r "$plugin_src_path/." "$plugin_dest_path"
}

"$@"

0 comments on commit e76836f

Please sign in to comment.