diff options
author | Quentin Young <qlyoung@nvidia.com> | 2021-08-30 01:33:34 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@nvidia.com> | 2021-08-30 17:38:01 +0200 |
commit | 661d41c183597dfaf3ed972822e3d94c48ab5784 (patch) | |
tree | 7dfe8a551c4b90907be54ee38571a02d4c14df25 /docker/alpine/Dockerfile | |
parent | Merge pull request #9503 from opensourcerouting/ospf6d-redistribute-metrics (diff) | |
download | frr-661d41c183597dfaf3ed972822e3d94c48ab5784.tar.xz frr-661d41c183597dfaf3ed972822e3d94c48ab5784.zip |
docker: build libyang2 along with FRR
Alpine images have been broken for some time because libyang2 is not
available in Alpine. This patch updates our Dockerfile to build a
libyang2 APK and install it into the image to satisfy FRR's libyang2
dependency.
Unfortunately, libyang2 erroneously includes an internal header from
glibc, making it dependent on glibc to build. FRR's official Docker
images are based on Alpine, which only offers musl libc. Until libyang2
fixes this problem, the libyang2 source that is installed in this image
is a patched version that is compatible with musl libc and not an
official version.
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'docker/alpine/Dockerfile')
-rw-r--r-- | docker/alpine/Dockerfile | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 8fc36c0e5..79ae31567 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -1,3 +1,26 @@ +# syntax=docker/dockerfile:1 + +# Create a basic stage set up to build APKs +FROM alpine:3.13 as alpine-builder +RUN apk add \ + --update-cache \ + abuild \ + alpine-conf \ + alpine-sdk \ + && setup-apkcache /var/cache/apk \ + && mkdir -p /pkgs/apk \ + && echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN adduser -D -G abuild builder && su builder -c 'abuild-keygen -a -n' + +# This stage builds a libyang APK from source +FROM alpine-builder as libyang-builder +RUN mkdir -p /libyang && chown -R builder /pkgs /libyang +COPY docker/alpine/libyang/ /libyang +USER builder +RUN cd /libyang \ + && abuild checksum \ + && abuild -r -P /pkgs/apk + # This stage builds a dist tarball from the source FROM alpine:3.13 as source-builder @@ -9,8 +32,15 @@ RUN source /src/alpine/APKBUILD.in \ --update-cache \ $makedepends \ gzip \ + py-pip \ && pip install pytest +RUN mkdir -p /pkgs/apk +COPY --from=libyang-builder /pkgs/apk/ /pkgs/apk/ +RUN apk add \ + --no-cache \ + --allow-untrusted /pkgs/apk/*/*.apk + COPY . /src ARG PKGVER RUN cd /src \ @@ -20,25 +50,17 @@ RUN cd /src \ --with-pkg-extra-version="_git$PKGVER" \ && make dist -# This stage builds an apk from the dist tarball -FROM alpine:3.13 as alpine-builder -# Don't use nocache here so that abuild can use the cache -RUN apk add \ - --update-cache \ - abuild \ - alpine-conf \ - alpine-sdk \ - py-pip \ - && pip install pytest \ - && setup-apkcache /var/cache/apk \ - && mkdir -p /pkgs/apk \ - && echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - +# This stage builds an APK from the dist tarball +FROM alpine-builder as frr-apk-builder +COPY --from=libyang-builder /pkgs/apk/ /pkgs/apk/ COPY --from=source-builder /src/frr-*.tar.gz /src/alpine/* /dist/ -RUN adduser -D -G abuild builder && chown -R builder /dist /pkgs +RUN find /pkgs/apk -type f -name APKINDEX.tar.gz -delete +RUN apk add \ + --no-cache \ + --allow-untrusted /pkgs/apk/*/*.apk +RUN chown -R builder /dist /pkgs USER builder RUN cd /dist \ - && abuild-keygen -a -n \ && abuild checksum \ && git init \ && abuild -r -P /pkgs/apk @@ -46,7 +68,7 @@ RUN cd /dist \ # This stage installs frr from the apk FROM alpine:3.13 RUN mkdir -p /pkgs/apk -COPY --from=alpine-builder /pkgs/apk/ /pkgs/apk/ +COPY --from=frr-apk-builder /pkgs/apk/ /pkgs/apk/ RUN apk add \ --no-cache \ --update-cache \ |