0

I'm very new to Linux overall and I'm trying to find a way to build a Debian package on an Alpine docker image. It is by far the fastest I can get my pipeline to run, but unfortunately when I try to run dpkg-deb --build I get the following error:

03:22:44 dpkg-deb: building package 'x-sync' in 'x-sync_1.0.2.deb'.
03:22:44 tar: unrecognized option: format=gnu
03:22:44 BusyBox v1.27.2 (2018-01-29 15:48:57 GMT) multi-call binary.
03:22:44 
03:22:44 Usage: tar -[cxtZzJjahmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
03:22:44 
03:22:44 Create, extract, or list files from a tar file
03:22:44 
03:22:44 Operation:
03:22:44    c   Create
03:22:44    x   Extract
03:22:44    t   List
03:22:44    f   Name of TARFILE ('-' for stdin/out)
03:22:44    C   Change to DIR before operation
03:22:44    v   Verbose
03:22:44    Z   (De)compress using compress
03:22:44    z   (De)compress using gzip
03:22:44    J   (De)compress using xz
03:22:44    j   (De)compress using bzip2
03:22:44    a   (De)compress using lzma
03:22:44    O   Extract to stdout
03:22:44    h   Follow symlinks
03:22:44    m   Don't restore mtime
03:22:44    exclude File to exclude
03:22:44    X   File with names to exclude
03:22:44    T   File with names to include
03:22:44 dpkg-deb: error: subprocess tar -cf returned error exit status 1

I attempted the packaging on the following Dockerfile:

FROM alpine
RUN apk add --no-cache dpkg openjdk8

Is there any way to build a Debian package on this distro that would be cross compatible with other distros, e.g. my Ubuntu dev environment?

  • What’s the basic problem you’re trying to solve by building the package in an Alpine-based Docker container? (There are a number of issues with this approach, including the use of Busybox, and more importantly the use of musl instead of glibc. They can be surmounted but I’d rather understand what you’re really trying to do before going into all that...) – Stephen Kitt Jun 15 '18 at 7:03
  • @StephenKitt I mostly seek the minimal image size that Alpine gives, it allows me to run builds a lot faster. I tried swapping alpine to bitnami/minideb and it works, as expected. So if I understand you right I shouldn't bother? – hochas Jun 15 '18 at 7:12
4

The best environment in which to build Debian packages is always a Debian-based environment. While Alpine-based containers are nice because of their small size and fast setup times, they introduce a number of issues, two of which are particularly troublesome:

  • they use Busybox, where Debian packages rely on the GNU variants of most tools (e.g. tar as you discovered);
  • most importantly, they use musl, where Debian defaults to glibc.

Both of these can be worked around, but by the time you do that you’ve lost the advantage of a small Alpine container, compared to a minimal Debian container (such as bitnami/minideb as you mentioned).

Note that if you’re running a Debian derivative on your development and/or build systems, you can skip the container stage entirely, while still using a contained build environment, by using pbuilder. For maximum speed, mount a tmpfs on /var/cache/pbuilder/build, and run the build with eatmydata. sbuild and cowbuilder are also worth looking into, especially if you regularly build similar packages.

As an aside, instead of building binary packages using dpkg-deb -b, I highly recommend learning how to build source packages; start with Vincent Bernat’s pragmatic Debian packaging, it’s nice and easy.

  • Amazing answer, above and beyond! I will have a look at the guide and see if I can improve my build process based on it. – hochas Jun 15 '18 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.