How to build UCS packages via Docker container
When packaging for UCS it is advisable to build packages from UCS itself. If there is no appropriate build host on hand, the generic Docker image can be used.
Preparing the build image
Step 1: Create Dockerfile
First we need to build a Docker image based on our generic UCS image. The following Dockerfile installs package build tools and starts with building a mounted package:
FROM univention/univention-corporate-server
ENV LANG=en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR /debbuilder/
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y dpkg-dev devscripts debhelper univention-config-dev ucslint rename \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT dh_clean \
&& apt update \
&& apt-get -q --assume-yes build-dep . \
&& dpkg-buildpackage -nc \
&& mkdir tmp \
&& cp ../*.deb tmp/ \
&& dh_clean \
&& cp tmp/*.deb . \
&& rm -r tmp
CMD chown $UID:$GID *.deb
Attention: You need to supply your own UID and GID, which can be detected via id
, or else the package will belong to root
.
Step 2: Build the image
Next the image has to be built: docker build -t ucsbuilder:latest .
(Optional) Step 3: Reconfigure locale
If the configurational files contain german umlauts the build might fail because the locale is wrong. The following steps will reconfigure the image to use a german locale:
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales
RUN sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& update-locale LANG=de_DE.UTF-8
ENV LANG de_DE.UTF-8
Package building
Created containers will immediately try to build from the current directory. Since /debbuilder
was specified as workdir the package sources have to be mounted accordingly:
docker run --rm -v $(pwd):/debbuilder ucsbuilder:latest
Optional: Lint only
If specified in the debian/control
, UCS will lint via ucslint
before building. To explicitly lint the package instead of building, the entrypoint can be overwritten:
docker run --rm -v $(pwd):/debbuilder --entrypoint ucslint ucsbuilder:latest
Further reading
- Overview of the Docker image: Docker
- Hints on
ucslint
: Univention Corporate Server - Manpage of
debhelper
: debhelper(7) — debhelper — Debian stretch — Debian Manpages