Skip to content

Instantly share code, notes, and snippets.

@Tarliton
Last active August 14, 2024 11:15
Show Gist options
  • Save Tarliton/ba786f6428248c037b576213fa595342 to your computer and use it in GitHub Desktop.
Save Tarliton/ba786f6428248c037b576213fa595342 to your computer and use it in GitHub Desktop.
Create borg universal package

Dockerfile that creates a static linked borg package and a Dockerfile.fuse that creates a static linked pyfuse3 package.

pyfuse3 is a dependency to mount borg repos.

It is useful when you do not want to install dependencies to compile it.

Usage:

  • check build.sh
  • run build.sh

You will end up with two wheels on the current directory.

#!/bin/bash
trap "exit" INT
python_version=cp312-cp312
llfuse_version=3.3.0
borg_version=1.4.0
llfuse_wheel_name=pyfuse3-$llfuse_version-$python_version-manylinux_2_28_x86_64.whl
llfuse_wheel_path=/pyfuse3/dist/wheelhouse/$llfuse_wheel_name
borg_wheel_name=borgbackup-$borg_version-$python_version-manylinux_2_28_x86_64.whl
borg_wheel_path=/borg/dist/wheelhouse/$borg_wheel_name
# pyfuse3
echo creating pyfuse3 $llfuse_version
docker build -f Dockerfile.fuse -t llfuse-$llfuse_version .
echo copying wheel $llfuse_wheel_name
echo
id_llfuse=$(docker create llfuse-$llfuse_version)
docker cp $id_llfuse:$llfuse_wheel_path - > $llfuse_wheel_name
docker rm -v $id_llfuse
# borg
echo creating borg $borg_version
docker build -t borg-$borg_version .
echo copying wheel $borg_wheel_name
echo
id_borg=$(docker create borg-$borg_version)
docker cp $id_borg:$borg_wheel_path - > $borg_wheel_name
docker rm -v $id_borg
FROM quay.io/pypa/manylinux_2_28_x86_64
ARG python_version=cp312-cp312
ARG borg_version=1.4.0
RUN yum -y update && \
yum -y install openssl-devel libacl-devel lz4-devel libzstd-devel xxhash-devel
RUN git clone https://github.com/borgbackup/borg.git
WORKDIR /borg
RUN git checkout $borg_version
RUN CFLAGS="-march=skylake -mtune=skylake" /opt/python/$python_version/bin/python3 -m build -v -w
RUN /opt/python/$python_version/bin/pip install auditwheel
WORKDIR /borg/dist/
RUN auditwheel repair borgbackup-$borg_version-$python_version-linux_x86_64.whl
FROM quay.io/pypa/manylinux_2_28_x86_64
ARG python_version=cp312-cp312
ARG pyfuse3_version=3.3.0
RUN yum -y update && \
yum -y install fuse3-devel
RUN git clone https://github.com/libfuse/pyfuse3.git
WORKDIR /pyfuse3
RUN git checkout $pyfuse3_version
RUN /opt/python/$python_version/bin/pip install cython auditwheel
RUN ln -s /opt/python/$python_version/bin/cython /usr/bin/cython
RUN /opt/python/$python_version/bin/python3 setup.py build_cython
RUN CFLAGS="-march=skylake -mtune=skylake" /opt/python/cp312-cp312/bin/python3 -m build -v -w
WORKDIR /pyfuse3/dist/
RUN auditwheel repair pyfuse3-$pyfuse3_version-$python_version-linux_x86_64.whl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment