From 25f83d89a5ea24c9241705bf2668e576c6c015ec Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 4 Dec 2020 16:15:04 +0100 Subject: [PATCH] Make docker determine the 'last tor version' and 'last torsocks version' This copies the logic from last_tor_version.sh and last_torsocks_version.sh into the Dockerfile itself. The Tor version can still be specified with the `tor_version` and `torsocks_version` arguments, as before. If these arguments are missing, the last versions are determined by the regular expression. This has a couple of advantages: 1) Users need not have git, make or docker-compose installed to build the image. 2) Users can build the image entirely inside a container which reduces the trust needed in the safety of the build instructions. 3) `git tag` is much quicker than `git ls-remote` since it operates on local data. --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 31c6636..b468241 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM python:3.8-alpine + +# if omitted, the versions are determined from the git tags ARG tor_version ARG torsocks_version @@ -9,7 +11,8 @@ RUN apk add --no-cache git bind-tools libevent-dev openssl-dev gnupg gcc mak mkdir -p /usr/local/src/ /var/lib/tor/ && \ git clone https://git.torproject.org/tor.git /usr/local/src/tor && \ cd /usr/local/src/tor && \ - git checkout tor-$tor_version && \ + TOR_VERSION=${tor_version=$(git tag | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)} && \ + git checkout tor-$TOR_VERSION && \ ./autogen.sh && \ ./configure \ --disable-asciidoc \ @@ -25,7 +28,8 @@ RUN apk add --no-cache git bind-tools libevent-dev openssl-dev gnupg gcc mak RUN apk add --no-cache git gcc make automake autoconf musl-dev libtool && \ git clone https://git.torproject.org/torsocks.git /usr/local/src/torsocks && \ cd /usr/local/src/torsocks && \ - git checkout $torsocks_version && \ + TORSOCKS_VERSION=${torsocks_version=$(git tag | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)} && \ + git checkout $TORSOCKS_VERSION && \ ./autogen.sh && \ ./configure && \ make && make install && \