From 6f08b02e90aa0adae3bafd524a5a53d85c886e4e Mon Sep 17 00:00:00 2001 From: Renuka Fernando Date: Sun, 16 Jun 2024 14:46:43 +0530 Subject: [PATCH] refactor: Update build-docker.sh to use CGO_ENABLED=0 for cross-compiling --- README.md | 7 ++++++- build-docker.sh | 4 ++-- main.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 72777d7..a3c8fb1 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,12 @@ curl https://localhost:8443/foo \ ## 2. Build From Source -run `./build-docker.sh` + +Execute the following command to build the Docker image. + +```sh +./build-docker.sh +``` ## 3. Deploy in Choreo diff --git a/build-docker.sh b/build-docker.sh index f853068..5c244da 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -4,8 +4,8 @@ IMAGE_NAME=renukafernando/request-info:latest # install docker buildx plugin -env GOOS=linux GOARCH=amd64 go build -o request-info-amd64 . -env GOOS=linux GOARCH=arm64 go build -o request-info-arm64 . +env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o request-info-amd64 . +env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o request-info-arm64 . #docker buildx build --push --platform linux/arm64/v8,linux/amd64 -t "$IMAGE_NAME" . docker build --build-arg TARGETARCH=arm64 -t "$IMAGE_NAME" . diff --git a/main.go b/main.go index 3714b68..6dd958f 100644 --- a/main.go +++ b/main.go @@ -237,7 +237,7 @@ func main() { flag.StringVar(&key, "key", "server.key", "Key file for HTTPS server") flag.StringVar(&clientCA, "ca", "ca.crt", "CA certificate file for client verification") flag.IntVar(&delayMs, "delayMs", 0, "Time to wait (ms) before responding to request") - flag.IntVar(&statusCode, "statusCode", 200, "HTTP status code to respond") + flag.IntVar(&statusCode, "status", 200, "HTTP status code to respond") flag.Parse() serviceName, _ = os.LookupEnv("NAME")