-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add build scripts that support the go plugin
Signed-off-by: Iceber Gu <[email protected]>
- Loading branch information
Showing
11 changed files
with
363 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* | ||
!/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
ARG BASEIMAGE | ||
ARG BUILDER_IMAGE | ||
ARG BASE_IMAGE | ||
|
||
FROM ${BASEIMAGE} | ||
ARG BINNAME | ||
COPY bin/${BINNAME} /usr/local/bin/${BINNAME} | ||
FROM --platform=$BUILDPLATFORM ${BUILDER_IMAGE} as builder | ||
WORKDIR /clusterpedia | ||
|
||
ARG BIN_NAME | ||
ARG ON_PLUGINS | ||
ARG TARGETARCH | ||
RUN GOARCH=${TARGETARCH} ON_PLUGINS=${ON_PLUGINS} make ${BIN_NAME} | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
ARG ON_PLUGINS | ||
RUN if [ "${ON_PLUGINS}" = "true" ]; then apk add --no-cache gcompat; fi | ||
|
||
ARG BIN_NAME | ||
COPY --from=builder /clusterpedia/bin/${BIN_NAME} /usr/local/bin/${BIN_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM golang:1.19.3 | ||
|
||
# FROM golang:1.19.2-alpine | ||
# RUN apk add --no-cache build-base git bash | ||
|
||
RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu | ||
|
||
COPY . /clusterpedia | ||
|
||
# RUN rm -rf /clusterpedia/.git | ||
# RUN rm -rf /clusterpedia/test | ||
|
||
ENV CLUSTERPEDIA_REPO="/clusterpedia" | ||
|
||
RUN cp /clusterpedia/hack/builder.sh / |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
OUTPUT_DIR=${OUTPUT_DIR:-$REPO_ROOT} | ||
CLUSTERPEDIA_REPO=${CLUSTERPEDIA_REPO:-$REPO_ROOT} | ||
|
||
GOOS=${GOOS:-$(go env GOOS)} | ||
GOARCH=${GOARCH:-$(go env GOARCH)} | ||
|
||
function build_component() { | ||
cd $CLUSTERPEDIA_REPO | ||
|
||
LDFLAGS=${BUILD_LDFLAGS:-""} | ||
if [ -f ./ldflags.sh ]; then | ||
source ./ldflags.sh | ||
fi | ||
CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o ${OUTPUT_DIR}/bin/$1 ./cmd/$1 | ||
} | ||
|
||
build_component $1 |
Oops, something went wrong.