Skip to content

Commit

Permalink
chore: versions of dependent packages are centrally managed in longho…
Browse files Browse the repository at this point in the history
…rn/dep-versions

Longhorn 10208

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Feb 7, 2025
1 parent 7e40dd0 commit b9785dc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 29 deletions.
39 changes: 12 additions & 27 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

ARG BRANCH=main

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

Expand All @@ -14,34 +16,16 @@ RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/syste

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 ${BRANCH} /usr/src/dep-versions

# 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 +43,8 @@ RUN zypper addrepo --refresh https://download.opensuse.org/repositories/system:/
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 46 in package/Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

package/Dockerfile#L46

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

Check warning on line 46 in package/Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

package/Dockerfile#L46

`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
55 changes: 53 additions & 2 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,67 @@ fi

cp -r bin package/

APIVERSION=`./bin/longhorn-share-manager version --client-only|jq ".clientVersion.apiVersion"`
#APIVERSION=`./bin/longhorn-share-manager version --client-only|jq ".clientVersion.apiVersion"`

# Try bin/longhorn-share-manager-amd64 and bin/longhorn-share-manager-arm64 doesn't have "Exec format error"
# if it is not "Exec format error", use it to get the version
#APIVERSION=`./bin/longhorn-share-manager version --client-only|jq ".clientVersion.apiVersion"`

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 29 in scripts/package

View check run for this annotation

codefactor.io / CodeFactor

scripts/package#L29

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 57 in scripts/package

View check run for this annotation

codefactor.io / CodeFactor

scripts/package#L57

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

BRANCH=$(get_branch)

# 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 BRANCH="${BRANCH}" \
-t "${IMAGE}" \
-f package/Dockerfile .

echo Built ${IMAGE}

Expand Down

0 comments on commit b9785dc

Please sign in to comment.