]> git.proxmox.com Git - mirror_frr.git/commitdiff
alpine packaging: build packages and base image directly from git
authorArthur Jones <arthur.jones@riverbed.com>
Wed, 4 Apr 2018 02:15:11 +0000 (19:15 -0700)
committerArthur Jones <arthur.jones@riverbed.com>
Wed, 4 Apr 2018 17:05:44 +0000 (10:05 -0700)
Currently, we tar up the git repo before building alpine packages.
This ensures that the packages we're building are exactly what is
checked in.  But, in practice, this restriction causes us to not
be able to build off of git contexts, which is a convenient feature
especially when using docker-compose.

So, here, we build the alpine packages directly from the contents
of the current directory and we install the packages into a base
image to ease downstream consumption.  There is still work to be
done in that area, as we need to package up the daemons, frr user
and all the rest, but that's for later...

Testing-done:

Built directly from the git repo, built from a reference to the
git repo and built using docker-compose, all seemed to work.  Also,
tested by @leleobhz and seems to build fine.

Thanks to Leonardo Amaral (@leleobhz) for reporting the issue and for
the original idea for a fix.

Issue: https://github.com/FRRouting/frr/issues/2024
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
.dockerignore [new file with mode: 0644]
doc/developer/building-frr-on-alpine.rst
docker/.gitignore
docker/alpine/Dockerfile
docker/alpine/build.sh

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..6b8710a
--- /dev/null
@@ -0,0 +1 @@
+.git
index 6fcb5de1076088833f30bf68971707c413622f26..f0f2aee138be256279db7d71cf1ccbd7124d3498 100644 (file)
@@ -34,26 +34,38 @@ This will put the apk packages in:
 Usage
 -----
 
-To add the packages to a docker image, create a Dockerfile in ./docker/pkgs:
+To create a base image with the frr packages installed:
 
 ::
 
-   FROM alpine:3.7
-   RUN mkdir -p /pkgs
-   ADD apk/ /pkgs/
-   RUN apk add --no-cache --allow-untrusted /pkgs/x86_64/*.apk
+   docker build --rm -f docker/alpine/Dockerfile -t frr:latest .
 
-And build a docker image:
+Or, if you don't have a git checkout of the sources, you can build a base
+image directly off the github account:
 
 ::
 
-   docker build --rm --force-rm -t alpine-dev-pkgs:latest docker/pkgs
+   docker build --rm -f docker/alpine/Dockerfile -t frr:latest \
+       https://github.com/frrouting/frr.git
 
-And run the image:
+And to run the image:
 
 ::
 
-   docker run -it --rm alpine-dev-pkgs:latest /bin/sh
+   docker run -it --rm frr:latest /bin/sh
 
 Currently, we only package the raw daemons and example files, so, you'll
 need to run the daemons by hand (or, better, orchestrate in the Dockerfile).
+
+We can also build directly from docker-compose, with a docker-compose.yml file
+like this one:
+
+::
+
+   version: '2.2'
+
+   services:
+      frr:
+         build:
+            context: https://github.com/frrouting/frr.git
+            dockerfile: docker/alpine/Dockerfile
index e9beab556ec34f397e80b463066c444bbdd16541..6f91eb5ec300db0d044eb93a1071225f4f6471e2 100644 (file)
@@ -1,2 +1 @@
-src.tar
 pkgs/
index e186fdccdf16b37d63248a72c8f9eabd1ffda469..6bd7d90aef4de859834ccb6b86c5163ede50846b 100644 (file)
@@ -12,8 +12,7 @@ RUN apk add --no-cache abuild acct alpine-sdk attr autoconf automake bash \
     patch pax-utils pcre perl pkgconf python2 python2-dev readline \
     readline-dev sqlite-libs squashfs-tools sudo tar texinfo xorriso xz-libs \
     groff gzip bc py-sphinx
-RUN mkdir -p /src
-ADD src.tar /src
+ADD . /src
 RUN (cd /src && \
        ./bootstrap.sh && \
        ./configure \
@@ -22,9 +21,13 @@ RUN (cd /src && \
        make dist)
 FROM alpine:3.7 as alpine-builder
 RUN apk add --no-cache abuild alpine-sdk && mkdir -p /pkgs/apk
-ADD alpine-build.sh /usr/bin/
-ADD builder /etc/sudoers.d
+ADD docker/alpine/alpine-build.sh /usr/bin/
+ADD docker/alpine/builder /etc/sudoers.d
 COPY --from=source-builder /src/*.tar.gz /src/alpine/APKBUILD /dist/
 RUN adduser -D -G abuild builder && chown -R builder /dist /pkgs
 USER builder
 RUN /usr/bin/alpine-build.sh
+FROM alpine:3.7
+RUN mkdir -p /pkgs/apk
+COPY --from=alpine-builder /pkgs/apk/ /pkgs/apk/
+RUN apk add --no-cache --allow-untrusted /pkgs/apk/x86_64/*.apk
index 357ea12dee81fab96ec29f9d3a56493cf7e63b68..40ed1194fe6cb23514352d146a30ec2f689b6f0c 100755 (executable)
@@ -9,12 +9,8 @@ set -x
 ##
 c=`git rev-parse --short=10 HEAD`
 commit=`printf '%u\n' 0x$c`
-git archive --format=tar $c > docker/alpine/src.tar
-(cd docker/alpine && \
-       docker build --build-arg commit=$commit --rm --force-rm -t \
-               frr:alpine-$c . && \
-       rm -f src.tar)
-
+docker build -f docker/alpine/Dockerfile \
+       --build-arg commit=$commit -t frr:alpine-$c .
 id=`docker create frr:alpine-$c`
 docker cp ${id}:/pkgs/ docker
 docker rm $id