Merge pull request #4030 from cfra/feature/fix-alpine-build

Fix alpine build
This commit is contained in:
Quentin Young 2019-03-28 12:02:59 -04:00 committed by GitHub
commit 8db37bf14a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 58 deletions

View File

@ -5,3 +5,4 @@
**/*.lo
**/*.so
**/.libs
docker/alpine/pkgs

View File

@ -9,13 +9,13 @@ license="GPL-2.0"
depends="json-c c-ares ipsec-tools iproute2 python py-ipaddr bash"
makedepends="ncurses-dev net-snmp-dev gawk texinfo perl
acct autoconf automake bash
binutils binutils-libs bison bsd-compat-headers build-base
binutils bison bsd-compat-headers build-base
c-ares c-ares-dev ca-certificates cryptsetup-libs curl
device-mapper-libs expat fakeroot flex fortify-headers gdbm
git gmp isl json-c-dev kmod lddtree libacl libatomic libattr
libblkid libburn libbz2 libc-dev libcap libcurl libedit libffi libgcc
libgomp libisoburn libisofs libltdl libressl libssh2
libstdc++ libtool libuuid linux-headers lzip lzo m4 make mkinitfs mpc1
libstdc++ libtool libuuid libyang-dev linux-headers lzip lzo m4 make mkinitfs mpc1
mpfr3 mtools musl-dev ncurses-libs ncurses-terminfo ncurses-terminfo-base
patch pax-utils pcre perl pkgconf python2 python2-dev readline
readline-dev sqlite-libs squashfs-tools sudo tar texinfo xorriso xz-libs
@ -23,7 +23,7 @@ makedepends="ncurses-dev net-snmp-dev gawk texinfo perl
checkdepends="pytest py-setuptools"
install="$pkgname.pre-install $pkgname.pre-deinstall $pkgname.post-deinstall"
subpackages="$pkgname-dev $pkgname-doc $pkgname-dbg"
source="$pkgname-$pkgver.tar.gz docker-start daemons"
source="$pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$pkgver
@ -60,8 +60,7 @@ package() {
cd "$builddir"
make DESTDIR="$pkgdir" install
install -Dm755 "$srcdir"/docker-start "$pkgdir"$_sbindir
install -Dm644 "$srcdir"/daemons "$pkgdir"$_sysconfdir
install -Dm644 "$builddir"/tools/etc/frr/daemons "$pkgdir"$_sysconfdir
install -d "$pkgdir"/etc/init.d
ln -s ${_sbindir}/frr "$pkgdir"/etc/init.d/frr
}

View File

@ -1,35 +1,58 @@
FROM alpine:3.7 as source-builder
ARG commit
RUN apk add --no-cache abuild acct alpine-sdk attr autoconf automake bash \
binutils binutils-libs bison bsd-compat-headers build-base \
c-ares c-ares-dev ca-certificates cryptsetup-libs curl \
device-mapper-libs expat fakeroot flex fortify-headers g++ gcc gdbm \
git gmp isl json-c json-c-dev kmod lddtree libacl libatomic libattr \
libblkid libburn libbz2 libc-dev libcap libcurl libedit libffi libgcc \
libgomp libisoburn libisofs libltdl libressl libssh2 \
libstdc++ libtool libuuid linux-headers lzip lzo m4 make mkinitfs mpc1 \
mpfr3 mtools musl-dev ncurses-libs ncurses-terminfo ncurses-terminfo-base \
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
ADD . /src
RUN (cd /src && \
./bootstrap.sh && \
./configure \
# This stage builds a dist tarball from the source
FROM alpine:edge as source-builder
RUN mkdir -p /src/alpine
COPY alpine/APKBUILD.in /src/alpine
RUN source /src/alpine/APKBUILD.in \
&& echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
&& apk add \
--no-cache \
--update-cache \
$makedepends \
gzip
COPY . /src
ARG PKGVER
RUN cd /src \
&& ./bootstrap.sh \
&& ./configure \
--enable-numeric-version \
--with-pkg-extra-version=_git$commit && \
make dist)
FROM alpine:3.7 as alpine-builder
RUN apk add --no-cache abuild alpine-sdk && mkdir -p /pkgs/apk
ADD docker/alpine/alpine-build.sh /usr/bin/
ADD docker/alpine/builder /etc/sudoers.d
COPY --from=source-builder /src/*.tar.gz /src/alpine/* /src/tools/etc/frr/daemons* /dist/
--with-pkg-extra-version="_git$PKGVER" \
&& make dist
# This stage builds an apk from the dist tarball
FROM alpine:edge as alpine-builder
# Don't use nocache here so that abuild can use the cache
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
&& 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
COPY --from=source-builder /src/frr-*.tar.gz /src/alpine/* /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 cd /dist \
&& abuild-keygen -a -n \
&& abuild checksum \
&& abuild -r -P /pkgs/apk
# This stage installs frr from the apk
FROM alpine:edge
RUN mkdir -p /pkgs/apk
COPY --from=alpine-builder /pkgs/apk/ /pkgs/apk/
RUN apk add --no-cache tini
RUN apk add --no-cache --allow-untrusted /pkgs/apk/x86_64/*.apk
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
&& apk add \
--no-cache \
--update-cache \
tini \
&& apk add \
--no-cache \
--allow-untrusted /pkgs/apk/*/*.apk \
&& rm -rf /pkgs
COPY docker/alpine/docker-start /usr/lib/frr/docker-start
ENTRYPOINT [ "/sbin/tini", "--", "/usr/lib/frr/docker-start" ]

View File

@ -1,11 +0,0 @@
#!/bin/sh
set -e
cd /dist
sudo apk --update add alpine-conf
sudo setup-apkcache /var/cache/apk
abuild-keygen -a -n
abuild checksum
abuild -r -P /pkgs/apk

View File

@ -1,17 +1,30 @@
#!/bin/sh
set -e
set -v
set -x
##
# commit must be converted to decimal
# Package version needs to be decimal
##
c=`git rev-parse --short=10 HEAD`
commit=`printf '%u\n' 0x$c`
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
docker rmi frr:alpine-$c
GITREV="$(git rev-parse --short=10 HEAD)"
PKGVER="$(printf '%u\n' 0x$GITREV)"
docker build \
--pull \
--file=docker/alpine/Dockerfile \
--build-arg="PKGVER=$PKGVER" \
--tag="frr:alpine-builder-$GITREV" \
--target=alpine-builder \
.
CONTAINER_ID="$(docker create "frr:alpine-builder-$GITREV")"
docker cp "${CONTAINER_ID}:/pkgs/" docker/alpine
docker rm "${CONTAINER_ID}"
docker build \
--file=docker/alpine/Dockerfile \
--build-arg="PKGVER=$PKGVER" \
--tag="frr:alpine-$GITREV" \
.
docker rmi "frr:alpine-builder-$GITREV"

View File

@ -1 +0,0 @@
builder ALL=(ALL) NOPASSWD:ALL

View File

@ -6,5 +6,7 @@ set -e
# For volume mounts...
##
chown -R frr:frr /etc/frr
/etc/init.d/frr start
exec sleep 10000d
/usr/lib/frr/frrinit.sh start
# Sleep forever
exec tail -f /dev/null