From: Christian Franke Date: Wed, 27 Mar 2019 12:29:04 +0000 (+0100) Subject: docker/alpine: Update buildscript to keep the docker image around X-Git-Tag: 7.1_pulled~127^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=eab6daa2a0462a5286a2a5fd6e17d17e3c49fa70;p=matthieu%2Ffrr.git docker/alpine: Update buildscript to keep the docker image around Don't delete the Alpine docker image after the build. Also, extract the packages from the build stage, so that we can remove them from the final image. --- diff --git a/.dockerignore b/.dockerignore index f2fc34583d..d613e18dfc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ **/*.lo **/*.so **/.libs +docker/alpine/pkgs diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 80ddb30d5b..815983a394 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -1,6 +1,5 @@ # This stage builds a dist tarball from the source FROM alpine:edge as source-builder -ARG commit RUN mkdir -p /src/alpine COPY alpine/APKBUILD.in /src/alpine @@ -13,11 +12,12 @@ RUN source /src/alpine/APKBUILD.in \ gzip COPY . /src +ARG PKGVER RUN cd /src \ && ./bootstrap.sh \ && ./configure \ --enable-numeric-version \ - --with-pkg-extra-version=_git$commit \ + --with-pkg-extra-version="_git$PKGVER" \ && make dist # This stage builds an apk from the dist tarball @@ -52,6 +52,7 @@ RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/reposit tini \ && apk add \ --no-cache \ - --allow-untrusted /pkgs/apk/*/*.apk + --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" ] diff --git a/docker/alpine/build.sh b/docker/alpine/build.sh index 5a79ebcdcb..22a36877c0 100755 --- a/docker/alpine/build.sh +++ b/docker/alpine/build.sh @@ -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/alpine -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"