From 88fe584fe13dc58478d3593793e99b286e505ac5 Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Fri, 27 Sep 2024 02:17:07 +0000 Subject: [PATCH] use a static build using musl on alpine to avoid dynamic loading issues that happen with NSS libraries on glibc --- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f52e968..0a9b135 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ +export PATH := $(PATH):$(HOME)/go/bin IMAGE?=fedora:latest +#LDFLAGS?=--ldflags '-extldflags "-static -ldl -lc -lm"' --ldflags="-X 'main.commit=$(shell git rev-parse HEAD)' -X 'main.version=$(shell git describe --tags)' -X 'main.date=$(shell date '+%Y-%m-%d %T.%s%z')'" +export CC?=muscl-gcc LDFLAGS?=--ldflags '-extldflags "-static"' --ldflags="-X 'main.commit=$(shell git rev-parse HEAD)' -X 'main.version=$(shell git describe --tags)' -X 'main.date=$(shell date '+%Y-%m-%d %T.%s%z')'" -export CGO_ENABLED=0 +export CGO_ENABLED=1 VERSION?=$(shell git describe --tags | sed -e 's/^v//' -e 's/-/_/g') .PHONY=jx-cli @@ -13,7 +16,7 @@ test: jx-cli go test -coverprofile=artifacts/coverage.profile ./... go tool cover -html=artifacts/coverage.profile -o artifacts/code-coverage.html fedora-deps: - dnf install -y nodejs git dnf-plugins-core rpm-build rpmdevtools + ./jx apply build/rpm.jx.yaml spectool -g -R build/jx.spec curl -L -o - https://go.dev/dl/go1.22.3.linux-amd64.tar.gz | tar -zxvf - rpm: fedora-deps @@ -26,10 +29,15 @@ ubuntu-deps: deb: ubuntu-deps : run: - docker run -it -v $(HOME)/.git-credentials:/root/.git-credentials -v $(HOME)/.gitconfig:/root/.gitconfig -v $(shell pwd):/src $(IMAGE) sh + docker run -it -v $(HOME)/.git-credentials:/root/.git-credentials -v $(HOME)/.gitconfig:/root/.gitconfig -v /var/run/docker.sock:/var/run/docker.sock -v $(shell pwd):/src $(IMAGE) sh +run-alpine: + docker run -it -v $(HOME)/.git-credentials:/root/.git-credentials -v $(HOME)/.gitconfig:/root/.gitconfig -v /var/run/docker.sock:/var/run/docker.sock -v $(shell pwd):/src golang:1.22.6-alpine sh clean: go clean -modcache rm jx +go-deps: + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + go install golang.org/x/vuln/cmd/govulncheck@latest lint: golangci-lint run --verbose ./... vulncheck: