From 0c4e24f3b7d5461ea65678324a770be6ce9ada39 Mon Sep 17 00:00:00 2001 From: Rafael Jung Date: Thu, 7 Jul 2022 00:47:31 +0200 Subject: [PATCH] Improve docs to use go cli instead of docker --- README.md | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a8689a6..f8db785 100644 --- a/README.md +++ b/README.md @@ -41,26 +41,18 @@ HEALTHCHECK CMD healthcheck ## Building -To build it for alpine, you can use the go-alpine image, for example (alternatively, for ARM64, you can use `docker run --rm -it arm64v8/golang:1.17-alpine`): +To build it for alpine, you can use the go-alpine image, for example (alternatively, for ARM64, you can use `docker run --rm -it arm64v8/golang:1.17-alpine`) or directly from the command line with go installed: ```bash -docker run --rm -it --platform linux/amd64 amd64/golang:1.17-alpine +go build healthcheck.go ``` -Then copy the go file to the running container: - -```bash -docker cp healthcheck.go CONTAINER_NAME:/go/healthcheck.go -``` +The binary will be created inside the current directory with name `healthcheck` -Build it from the container +Or alternatively for other operational systems or architectures, use respectively the envs `GOOS` and `GOARCH` (for better portability, make sure to use static linking with `CGO_ENABLED=0`): ```bash -go build healthcheck.go -``` +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o healthcheck_linux_amd64 healthcheck.go -And copy back the binary to the host - -```bash -docker cp CONTAINER_NAME:/go/healthcheck healthcheck +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o healthcheck_linux_arm64 healthcheck.go ```