summaryrefslogtreecommitdiffstats
path: root/docker/alpine
diff options
context:
space:
mode:
Diffstat (limited to 'docker/alpine')
-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"