Skip to content

Commit ab93457

Browse files
author
Paulo Gomes
committed
Bump libgit2 dependencies to debian bookworm
Signed-off-by: Paulo Gomes <[email protected]>
1 parent b91f49c commit ab93457

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

.github/actions/run-tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG GO_VERSION=1.17.5
33
ARG XX_VERSION=1.1.0
44

55
ARG LIBGIT2_IMG=ghcr.io/fluxcd/golang-with-libgit2
6-
ARG LIBGIT2_TAG=libgit2-1.1.1-2
6+
ARG LIBGIT2_TAG=libgit2-1.1.1-3
77

88
FROM tonistiigi/xx:${XX_VERSION} AS xx
99
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} as libgit2

Dockerfile

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG GO_VERSION=1.17
33
ARG XX_VERSION=1.1.0
44

55
ARG LIBGIT2_IMG=ghcr.io/fluxcd/golang-with-libgit2
6-
ARG LIBGIT2_TAG=libgit2-1.1.1-2
6+
ARG LIBGIT2_TAG=libgit2-1.1.1-3
77

88
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
99
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} as libgit2
@@ -16,6 +16,15 @@ FROM go-${TARGETOS} AS build-base-bullseye
1616

1717
# Copy the build utilities
1818
COPY --from=xx / /
19+
20+
# Align golang base image with bookworm.
21+
# TODO: Replace this with a golang bookworm variant, once that is released.
22+
RUN echo "deb http://deb.debian.org/debian bookworm main" > /etc/apt/sources.list.d/bookworm.list \
23+
&& echo "deb-src http://deb.debian.org/debian bookworm main" /etc/apt/sources.list.d/bookworm.list \
24+
&& xx-apt update \
25+
&& xx-apt -t bookworm upgrade -y \
26+
&& xx-apt -t bookworm install -y curl
27+
1928
COPY --from=libgit2 /Makefile /libgit2/
2029

2130
# Install the libgit2 build dependencies
@@ -28,9 +37,6 @@ FROM build-base-${BASE_VARIANT} as libgit2-bullseye
2837

2938
ARG TARGETPLATFORM
3039

31-
# build libgit2 in release mode
32-
ARG BUILD_TYPE=Release
33-
3440
# First build libgit2 statically, this ensures that all its dependencies
3541
# will be statically available as well.
3642
ARG BUILD_SHARED_LIBS=OFF
@@ -39,6 +45,8 @@ RUN FLAGS=$(xx-clang --print-cmake-defines) make -C /libgit2 libgit2
3945
# Rebuild libgit2 this time to generate the shared libraries.
4046
ARG BUILD_SHARED_LIBS=ON
4147
RUN FLAGS=$(xx-clang --print-cmake-defines) make -C /libgit2 libgit2
48+
# Logs glibc version used at built time. The final image must be compatible with it.
49+
RUN ldd --version ldd > /libgit2/built-on-glibc-version
4250

4351

4452
FROM libgit2-${BASE_VARIANT} as build
@@ -70,20 +78,25 @@ ARG TARGETPLATFORM
7078
# Others (such as libc, librt, libdl and libpthread) are resolved at run-time.
7179
# To decrease the likelihood of such dependencies being out of sync, the base build image
7280
# should be aligned with the target (i.e. same debian variant).
73-
RUN xx-go build \
74-
-ldflags "-s -w -extldflags \"/usr/lib/$(xx-info triple)/libssh2.a /usr/lib/$(xx-info triple)/libssl.a /usr/lib/$(xx-info triple)/libcrypto.a /usr/lib/$(xx-info triple)/libz.a -Wl,--unresolved-symbols=ignore-in-object-files -Wl,-allow-shlib-undefined -static\"" \
75-
-tags 'netgo,osusergo,static_build' -o source-controller -trimpath main.go;
81+
RUN FLAGS=$(pkg-config --static --libs --cflags libssh2 libgit2 libssl libcrypto zlib openssl) \
82+
xx-go build \
83+
-ldflags "-s -w -extldflags \"/usr/lib/$(xx-info triple)/libssh2.a /usr/lib/$(xx-info triple)/libssl.a /usr/lib/$(xx-info triple)/libcrypto.a /usr/lib/$(xx-info triple)/libz.a -Wl,--unresolved-symbols=ignore-in-object-files -Wl,-allow-shlib-undefined ${FLAGS} -static\"" \
84+
-tags 'netgo,osusergo,static_build' \
85+
-o source-controller -trimpath main.go;
7686

77-
# Cannot use distroless/static due to lingering dependencies on libnss.
78-
FROM gcr.io/distroless/base-debian11 as controller
87+
# The target image must aligned with apt sources used for libgit2.
88+
FROM debian:bookworm-slim as controller
7989

8090
# Link repo to the GitHub Container Registry image
8191
LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller"
8292

93+
ARG TARGETPLATFORM
94+
RUN apt update && apt install -y ca-certificates
95+
8396
# Copy over binary from build
8497
COPY --from=build /workspace/source-controller /usr/local/bin/
98+
COPY --from=libgit2-bullseye /libgit2/built-on-glibc-version /
8599
COPY ATTRIBUTIONS.md /
86100

87-
# leverages nonroot available in gcr.io/distroless/base-debian11
88-
USER nonroot
101+
USER 65534:65534
89102
ENTRYPOINT [ "source-controller" ]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TAG ?= latest
44

55
# Base image used to build the Go binary
66
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
7-
LIBGIT2_TAG ?= libgit2-1.1.1-2
7+
LIBGIT2_TAG ?= libgit2-1.1.1-3
88

99
# Allows for defining additional Docker buildx arguments,
1010
# e.g. '--push'.

hack/ci/e2e.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ function cleanup(){
5454
}
5555
trap cleanup EXIT
5656

57+
# Wait for nodes to be ready and pods to be running
5758
kubectl wait node "${KIND_CLUSTER_NAME}-control-plane" --for=condition=ready --timeout=2m
59+
kubectl wait --for=condition=ready -n kube-system -l k8s-app=kube-dns pod
60+
kubectl wait --for=condition=ready -n local-path-storage -l app=local-path-provisioner pod
5861

5962
echo "Build, load image into kind and deploy controller"
6063
make docker-build IMG="${IMG}" TAG="${TAG}" BUILD_PLATFORMS="${BUILD_PLATFORM}" BUILD_ARGS=--load

hack/update-attributions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ https://github.com/libssh2/libssh2/
1919
2020
No changes were made to its original source code.
2121
22-
Copyright notice (https://raw.githubusercontent.com/libssh2/libssh2/main/COPYING):
22+
Copyright notice (https://raw.githubusercontent.com/libssh2/libssh2/master/COPYING):
2323
2424
$(curl --max-time 5 -L https://raw.githubusercontent.com/libssh2/libssh2/master/COPYING)
2525

0 commit comments

Comments
 (0)