summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorChristian Franke <chris@opensourcerouting.org>2019-03-27 13:29:04 +0100
committerChristian Franke <chris@opensourcerouting.org>2019-03-27 15:39:54 +0100
commiteab6daa2a0462a5286a2a5fd6e17d17e3c49fa70 (patch)
tree050e0ef2d10f12150d8dbe28fdc9bf90417ee4c9 /docker
parentdocker/alpine/build.sh: Install packages to docker/alpine (diff)
downloadfrr-eab6daa2a0462a5286a2a5fd6e17d17e3c49fa70.tar.xz
frr-eab6daa2a0462a5286a2a5fd6e17d17e3c49fa70.zip
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.
Diffstat (limited to 'docker')
-rw-r--r--docker/alpine/Dockerfile7
-rwxr-xr-xdocker/alpine/build.sh33
2 files changed, 27 insertions, 13 deletions
diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile
index 80ddb30d5..815983a39 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 5a79ebcdc..22a36877c 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"