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.
This commit is contained in:
Christian Franke 2019-03-27 13:29:04 +01:00
parent eb3400c12b
commit eab6daa2a0
3 changed files with 28 additions and 13 deletions

View file

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

View file

@ -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" ]

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/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"