Code Monkey home page Code Monkey logo

docker-deb-builder's Introduction

Creating Debian packages in Docker container

Overview

Docker can be used to set up a clean build environment for Debian packaging. This tutorial shows how to create a container with required build tools and how to use it to build packages.

For more complete solution with many improvements see container-deb-builder.

Create build environment

Start by building a container that will act as package build environment:

docker build -t docker-deb-builder:17.04 -f Dockerfile-ubuntu-17.04 .

In this example the target is Ubuntu 17.04 but you can create and modify Dockerfile-nnn to match your target environment.

Building packages

First download or git clone the source code of the package you are building:

git clone ... ~/my-package-source

The source code should contain subdirectory called debian with at least a minimum set of packaging files: control, copyright, changelog and rules.

Clone the docker-deb-builder (the repository you are reading now) and run the build script to see usage:

$ ./build
usage: build [options...] SOURCEDIR
Options:
  -i IMAGE  Name of the docker image (including tag) to use as package build environment.
  -o DIR    Destination directory to store packages to.
  -d DIR    Directory that contains other deb packages that need to be installed before build.

To build Debian packages run following commands:

# create destination directory to store the build results
mkdir output

# build package from source directory
./build -i docker-deb-builder:17.04 -o output ~/my-package-source

After successful build you will find the .deb files in output directory.

Sometimes build might require dependencies that cannot be installed with apt-get build-dep. You can install them into the build environment by passing option -d DIR where DIR is a directory with *.deb files in it.

./build -i docker-deb-builder:17.04 -o output -d dependencies ~/my-package-source

Integrating with CI

In this tutorial all package-specific build dependencies are installed from scratch each time build is executed in the container. The benefit is that the container is generic and reusable for building any package but the installation of build-time dependencies can add up to considerable overhead, both in time and bandwidth. This overhead may not be acceptable when building packages as part of continuous integration pipeline. One possible solution to reduce overhead is to install package-specific build dependencies into build environment container.

docker-deb-builder's People

Contributors

apiraino avatar cedr-x avatar neszt avatar psychonaut avatar tsaarni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-deb-builder's Issues

Failure with Debian bookworm

Seems like /etc/apt/sources.list has been removed?

voltagex@debian:~/src/docker-deb-builder$ docker build -t docker-deb-builder:debian-bookworm -f Dockerfile-Debian-bookworm-12 .
#0 building with "default" instance using docker driver

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.1s

#2 [internal] load build definition from Dockerfile-Debian-bookworm-12
#2 transferring dockerfile: 671B done
#2 DONE 0.1s

#3 [internal] load metadata for docker.io/library/debian:bookworm
#3 ...

#4 [auth] library/debian:pull token for registry-1.docker.io
#4 DONE 0.0s

#3 [internal] load metadata for docker.io/library/debian:bookworm
#3 DONE 2.9s

#5 [1/7] FROM docker.io/library/debian:bookworm@sha256:9f76a008888da28c6490bedf7bdaa919bac9b2be827afd58d6eb1b916e1e5918
#5 resolve docker.io/library/debian:bookworm@sha256:9f76a008888da28c6490bedf7bdaa919bac9b2be827afd58d6eb1b916e1e5918 0.0s done
#5 sha256:278727474c2935fca471835f8e09a78631bf93d6a414979f038abebc315fb8da 1.46kB / 1.46kB done
#5 sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 0B / 49.56MB 0.1s
#5 sha256:9f76a008888da28c6490bedf7bdaa919bac9b2be827afd58d6eb1b916e1e5918 1.85kB / 1.85kB done
#5 sha256:f2150eba68619015058b26d50e47f9fba81213d1cb81633be7928c830f72d180 529B / 529B done
#5 sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 18.87MB / 49.56MB 0.5s
#5 sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 30.41MB / 49.56MB 0.6s
#5 sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 49.56MB / 49.56MB 0.8s done
#5 extracting sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 0.1s
#5 extracting sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 1.3s done
#5 DONE 2.3s

#6 [2/7] RUN sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list
#6 0.699 sed: can't read /etc/apt/sources.list: No such file or directory
#6 ERROR: process "/bin/sh -c sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list" did not complete successfully: exit code: 2
------
 > [2/7] RUN sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list:
0.699 sed: can't read /etc/apt/sources.list: No such file or directory
------
Dockerfile-Debian-bookworm-12:3
--------------------
   1 |     FROM debian:bookworm
   2 |
   3 | >>> RUN sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list
   4 |     RUN echo 'man-db man-db/auto-update boolean false' | debconf-set-selections
   5 |     RUN set -ex \
--------------------
ERROR: failed to solve: process "/bin/sh -c sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list" did not complete successfully: exit code: 2
voltagex@debian:~/src/docker-deb-builder$ docker run -it debian:bookworm
Unable to find image 'debian:bookworm' locally
bookworm: Pulling from library/debian
785ef8b9b236: Already exists
Digest: sha256:9f76a008888da28c6490bedf7bdaa919bac9b2be827afd58d6eb1b916e1e5918
Status: Downloaded newer image for debian:bookworm
root@8c976d4db3f7:/# cat /etc/apt/sources.list.d/debian.sources
Types: deb
# http://snapshot.debian.org/archive/debian/20230725T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
# http://snapshot.debian.org/archive/debian-security/20230725T000000Z
URIs: http://deb.debian.org/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
root@8c976d4db3f7:/#

Ubuntu 20.04

Many changes that is needed to have dockerfile for 20.04?

mk-build-deps build failure (usage printout)

Fails to build with printing out help for mk-build-deps:

(base) [sm@fedora-mbp docker-deb-builder]$ ./build -i docker-deb-builder:20.04 -o output ./sources/bmxlib-libmxf
Running docker:
docker run -it -it -v /home/sm/work/docker-deb-builder/sources/bmxlib-libmxf:/source-ro:ro -v /home/sm/work/docker-deb-builder/output:/output -v /home/sm/work/docker-deb-builder/build-helper.sh:/build-helper.sh:ro -e USER=1000 -e GROUP=1000 --rm  docker-deb-builder:20.04 /build-helper.sh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Usage:
    mk-build-deps --help|--version

    mk-build-deps [options] control file | package name ...

Do you have any ideas on what should I check? I thought about the dependencies list but it seems to be fine.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.