Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: versions of dependent packages are centrally managed in longhorn/dep-versions #445

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

FROM registry.suse.com/bci/bci-base:15.6 AS build

ARG SRC_BRANCH=main
ARG SRC_TAG

RUN zypper -n ref && \
zypper update -y

Expand All @@ -14,34 +17,21 @@

RUN zypper -n install autoconf bison curl cmake doxygen make git gcc14 gcc14-c++ flex Mesa-libGL-devel libdbus-1-3 \
nfsidmap-devel liburcu-devel libblkid-devel e2fsprogs e2fsprogs-devel xfsprogs xfsprogs-devel \
tar gzip dbus-1-devel lsb-release graphviz-devel libnsl-devel libcurl-devel libjson-c-devel libacl-devel && \
tar gzip dbus-1-devel lsb-release graphviz-devel libnsl-devel libcurl-devel libjson-c-devel libacl-devel jq && \
rm -rf /var/cache/zypp/*

RUN curl -L https://github.com/rancher/nfs-ganesha/archive/refs/tags/v6_20250113.tar.gz | tar zx \
&& curl -L https://github.com/nfs-ganesha/ntirpc/archive/refs/tags/v6.3.tar.gz | tar zx \
&& mv nfs-ganesha-6_20250113 nfs-ganesha \
&& rm -r nfs-ganesha/src/libntirpc \
&& mv ntirpc-6.3 nfs-ganesha/src/libntirpc
WORKDIR /nfs-ganesha

# build ganesha only supporting nfsv4 and vfs
# Set NFS_V4_RECOV_ROOT to /tmp we don't support recovery in this release
# we disable dbus (-DUSE_DBUS=OFF) for the single share manager since we don't use dynamic exports
ENV CC=/usr/bin/gcc-14 \
CXX=/usr/bin/g++-14
RUN mkdir -p /usr/local \
&& cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_CONFIG=vfs_only \
-DUSE_DBUS=OFF -DUSE_NLM=OFF -DUSE_RQUOTA=OFF -DUSE_9P=OFF -D_MSPAC_SUPPORT=OFF -DRPCBIND=OFF \
-DUSE_RADOS_RECOV=OFF -DRADOS_URLS=OFF -DUSE_FSAL_VFS=ON -DUSE_FSAL_XFS=OFF \
-DUSE_FSAL_PROXY_V4=OFF -DUSE_FSAL_PROXY_V3=OFF -DUSE_FSAL_LUSTRE=OFF -DUSE_FSAL_LIZARDFS=OFF \
-DUSE_FSAL_KVSFS=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_GPFS=OFF -DUSE_FSAL_PANFS=OFF -DUSE_FSAL_GLUSTER=OFF \
-DUSE_GSS=NO -DHAVE_ACL_GET_FD_NP=ON -DHAVE_ACL_SET_FD_NP=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local src/ \
&& make \
&& make install
RUN mkdir -p /ganesha-extra \
&& mkdir -p /ganesha-extra/etc/dbus-1/system.d \
&& cp src/scripts/ganeshactl/org.ganesha.nfsd.conf /ganesha-extra/etc/dbus-1/system.d/
RUN git clone https://github.com/longhorn/dep-versions.git -b ${SRC_BRANCH} /usr/src/dep-versions && \
cd /usr/src/dep-versions && \
if [ -n "${SRC_TAG}" ] && git show-ref --tags ${SRC_TAG} > /dev/null 2>&1; then \
echo "Checking out tag ${SRC_TAG}"; \
cd /usr/src/dep-versions && git checkout tags/${SRC_TAG}; \
fi

# Build nfs-ganesha
RUN export REPO_OVERRIDE="" && \
export COMMIT_ID_OVERRIDE="" && \
bash /usr/src/dep-versions/scripts/build-nfs-ganesha.sh "${REPO_OVERRIDE}" "${COMMIT_ID_OVERRIDE}"


FROM registry.suse.com/bci/bci-base:15.6

Expand All @@ -59,7 +49,8 @@
zypper --gpg-auto-import-keys ref

# RUN microdnf install -y nano tar lsof e2fsprogs fuse-libs libss libblkid userspace-rcu dbus-x11 rpcbind hostname nfs-utils xfsprogs jemalloc libnfsidmap && microdnf clean all
RUN zypper -n install rpcbind hostname libblkid1 liburcu6 libjson-c* dbus-1-x11 dbus-1 nfsidmap-devel nfs-kernel-server nfs-client nfs4-acl-tools xfsprogs e2fsprogs awk && \
RUN zypper -n install rpcbind hostname libblkid1 liburcu6 libjson-c* dbus-1-x11 dbus-1 nfsidmap-devel \

Check warning on line 52 in package/Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

package/Dockerfile#L52

Specify version with `zypper install -y <package>=<version>`. (DL3037)

Check warning on line 52 in package/Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

package/Dockerfile#L52

`zypper clean` missing after zypper use. (DL3036)
nfs-kernel-server nfs-client nfs4-acl-tools xfsprogs e2fsprogs awk && \
rm -rf /var/cache/zypp/*

RUN mkdir -p /var/run/dbus && mkdir -p /export
Expand Down
49 changes: 47 additions & 2 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,61 @@

cp -r bin package/

APIVERSION=`./bin/longhorn-share-manager version --client-only|jq ".clientVersion.apiVersion"`
arch=$(uname -m)
if [ "$arch" == "aarch64" ]; then
ARCH="arm64"
else
ARCH="amd64"
fi
APIVERSION=`./bin/longhorn-share-manager-"$ARCH" version --client-only|jq ".clientVersion.apiVersion"`

Check notice on line 22 in scripts/package

View check run for this annotation

codefactor.io / CodeFactor

scripts/package#L22

Use $(...) notation instead of legacy backticks `...`. (SC2006)

TAG=${TAG:-"v${APIVERSION}_`date -u +%Y%m%d`"}
REPO=${REPO:-longhornio}
IMAGE=${REPO}/${PROJECT}:${TAG}

function convert_version_to_major_minor_x() {
local version="$1"
if [[ "$version" =~ ^v([0-9]+)\.([0-9]+)\. ]]; then
echo "v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.x"
else
echo "Invalid version format: $version"
fi
}

function get_branch() {
local version_file="version"
if [[ ! -f $version_file ]]; then
echo "Error: Version file '$version_file' not found."
exit 1
fi

local version=$(cat "$version_file")
local branch=$(convert_version_to_major_minor_x "$version")

# Fetch versions.json from the appropriate branch, fallback to main
wget -q "https://raw.githubusercontent.com/longhorn/dep-versions/${branch}/versions.json" -O /versions.json
if [ $? -eq 0 ]; then

Check notice on line 49 in scripts/package

View check run for this annotation

codefactor.io / CodeFactor

scripts/package#L49

Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. (SC2181)
echo "${branch}"
else
echo "main"
fi
}

SRC_BRANCH=$(get_branch)
SRC_TAG=$(git tag --points-at HEAD | head -n 1)

# update base image to get latest changes
BASE_IMAGE=`grep FROM package/Dockerfile | grep -v AS | awk '{print $2}'`
docker pull ${BASE_IMAGE}

buildx build --load -t ${IMAGE} -f package/Dockerfile .
echo "Building image ${IMAGE} based on ${BASE_IMAGE}"
buildx build \
--load \
--build-arg ARCH="${ARCH}" \
--build-arg SRC_BRANCH="${SRC_BRANCH}" \
--build-arg SRC_TAG="${SRC_TAG}" \
-t "${IMAGE}" \
-f package/Dockerfile .

echo Built ${IMAGE}

Expand Down