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 **/*.lo
**/*.so **/*.so
**/.libs **/.libs
docker/alpine/pkgs

View file

@ -1,6 +1,5 @@
# This stage builds a dist tarball from the source # This stage builds a dist tarball from the source
FROM alpine:edge as source-builder FROM alpine:edge as source-builder
ARG commit
RUN mkdir -p /src/alpine RUN mkdir -p /src/alpine
COPY alpine/APKBUILD.in /src/alpine COPY alpine/APKBUILD.in /src/alpine
@ -13,11 +12,12 @@ RUN source /src/alpine/APKBUILD.in \
gzip gzip
COPY . /src COPY . /src
ARG PKGVER
RUN cd /src \ RUN cd /src \
&& ./bootstrap.sh \ && ./bootstrap.sh \
&& ./configure \ && ./configure \
--enable-numeric-version \ --enable-numeric-version \
--with-pkg-extra-version=_git$commit \ --with-pkg-extra-version="_git$PKGVER" \
&& make dist && make dist
# This stage builds an apk from the dist tarball # 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 \ tini \
&& apk add \ && apk add \
--no-cache \ --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 COPY docker/alpine/docker-start /usr/lib/frr/docker-start
ENTRYPOINT [ "/sbin/tini", "--", "/usr/lib/frr/docker-start" ] ENTRYPOINT [ "/sbin/tini", "--", "/usr/lib/frr/docker-start" ]

View file

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