Skip to content

Commit

Permalink
TEMPORARY COMMIT - Bump libgit2 image to 1.1.1-5
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
  • Loading branch information
Paulo Gomes committed Feb 1, 2022
1 parent a923945 commit cb15586
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Run tests
run: make test
- name: Prepare
id: prep
run: |
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ ENV CGO_ENABLED=1
RUN export $(cat build/musl/$(xx-info alpine-arch).env | xargs) && \
export LIBRARY_PATH="/usr/local/$(xx-info triple):/usr/local/$(xx-info triple)/lib64" && \
export PKG_CONFIG_PATH="/usr/local/$(xx-info triple)/lib/pkgconfig:/usr/local/$(xx-info triple)/lib64/pkgconfig" && \
export FLAGS="$(pkg-config --static --libs --cflags libssh2 openssl libgit2)" && \
export CGO_LDFLAGS="${FLAGS} -static" && \
export CGO_LDFLAGS="$(pkg-config --static --libs --cflags libssh2 openssl libgit2) -static" && \
GOARCH=$TARGETARCH go build \
-ldflags "-s -w" \
-tags 'netgo,osusergo,static_build' \
Expand Down
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ IMG ?= fluxcd/source-controller
TAG ?= latest

# Base image used to build the Go binary
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
LIBGIT2_TAG ?= libgit2-1.1.1-4
LIBGIT2_IMG ?= quay.io/paulinhu/golang-with-libgit2
LIBGIT2_TAG ?= libgit2-1.1.1-5

# Allows for defining additional Docker buildx arguments,
# e.g. '--push'.
Expand All @@ -30,7 +30,7 @@ MUSL-CC =

export CGO_ENABLED=1
export PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig:$(LIBGIT2_LIB64_PATH)/pkgconfig
export LD_LIBRARY_PATH=$(LIBGIT2_LIB_PATH):$(LIBGIT2_LIB64_PATH)
export LIBRARY_PATH=$(LIBGIT2_LIB_PATH):$(LIBGIT2_LIB64_PATH)
export CGO_CFLAGS=-I$(LIBGIT2_PATH)/include -I$(LIBGIT2_PATH)/include/openssl

ifeq ($(shell uname -s),Darwin)
Expand All @@ -41,11 +41,18 @@ endif


ifeq ($(shell uname -s),Linux)
ifeq ($(shell uname -m),x86_64)
# Linux x86_64 seem to be able to cope with the static libraries
# by having only musl-dev installed, without the need of using musl toolchain.
GO_STATIC_FLAGS=-ldflags "-s -w" -tags 'netgo,osusergo,static_build'
else
MUSL-PREFIX=$(REPOSITORY_ROOT)/build/musl/$(shell uname -m)-linux-musl-native/bin/$(shell uname -m)-linux-musl
MUSL-CC=$(MUSL-PREFIX)-gcc
export CC=$(MUSL-PREFIX)-gcc
export CXX=$(MUSL-PREFIX)-g++
export AR=$(MUSL-PREFIX)-ar
GO_STATIC_FLAGS=-ldflags "-s -w -extldflags \"-static\"" -tags 'netgo,osusergo,static_build'
endif
endif

# API (doc) generation utilities
Expand All @@ -59,7 +66,6 @@ else
GOBIN=$(shell go env GOBIN)
endif


# Architecture to use envtest with
ifeq ($(shell uname -m),x86_64)
ENVTEST_ARCH ?= amd64
Expand All @@ -70,21 +76,18 @@ endif
all: build

build: $(LIBGIT2) ## Build manager binary
go build -o bin/manager main.go
go build $(GO_STATIC_FLAGS) -o bin/manager main.go

KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
test: $(LIBGIT2) install-envtest test-api ## Run tests
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
go test ./... \
-ldflags "-s -w" \
-coverprofile cover.out \
-tags 'netgo,osusergo,static_build'
go test $(GO_STATIC_FLAGS) ./... -coverprofile cover.out

test-api: ## Run api tests
cd api; go test ./... -coverprofile cover.out

run: $(LIBGIT2) generate fmt vet manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
go run ./main.go
go run $(GO_STATIC_FLAGS) ./main.go

install: manifests ## Install CRDs into a cluster
kustomize build config/crd | kubectl apply -f -
Expand Down Expand Up @@ -192,7 +195,8 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
TMP_DIR=$(REPOSITORY_ROOT)/build/tmp ;\
mkdir -p $$TMP_DIR ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
Expand Down
4 changes: 2 additions & 2 deletions hack/download-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ MUSL_DIR="${ROOT_DIR}/build/musl"
if [ "${TARGET_ARCH}" = "$(uname -m)" ]; then
MUSL_FILENAME="${MUSL_X86_64_FILENAME}"
MUSL_SHA512="${MUSL_X86_64_SHA512}"
MUSL_PREFIX=$(xx-info alpine-arch)-linux-musl-native/bin/$(xx-info alpine-arch)-linux-musl
MUSL_PREFIX="${TARGET_ARCH}-linux-musl-native/bin/${TARGET_ARCH}-linux-musl"
if [ "${TARGET_ARCH}" = "arm64" ] || [ "${TARGET_ARCH}" = "aarch64" ]; then
MUSL_FILENAME="${MUSL_AARCH64_FILENAME}"
MUSL_SHA512="${MUSL_AARCH64_SHA512}"
fi
else
MUSL_FILENAME="${MUSL_XX86_64_FILENAME}"
MUSL_SHA512="${MUSL_XX86_64_SHA512}"
MUSL_PREFIX=$(xx-info alpine-arch)-linux-musl-cross/bin/$(xx-info alpine-arch)-linux-musl
MUSL_PREFIX="${TARGET_ARCH}-linux-musl-cross/bin/${TARGET_ARCH}-linux-musl"
if [ "${TARGET_ARCH}" = "arm64" ] || [ "${TARGET_ARCH}" = "aarch64" ]; then
MUSL_FILENAME="${MUSL_XAARCH64_FILENAME}"
MUSL_SHA512="${MUSL_XAARCH64_SHA512}"
Expand Down

0 comments on commit cb15586

Please sign in to comment.