From 7fe3c965e33eee42281d3889f48fd7bf57eb52f8 Mon Sep 17 00:00:00 2001 From: Henrik Lundahl Date: Thu, 9 Apr 2020 08:21:35 +0200 Subject: [PATCH] Add a version build arg to the Alpine Dockerfile. --- docker/sftpgo/alpine/Dockerfile | 7 ++++--- docker/sftpgo/alpine/README.md | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/sftpgo/alpine/Dockerfile b/docker/sftpgo/alpine/Dockerfile index da315543..a4572f2b 100644 --- a/docker/sftpgo/alpine/Dockerfile +++ b/docker/sftpgo/alpine/Dockerfile @@ -3,8 +3,9 @@ FROM golang:alpine as builder RUN apk add --no-cache git gcc g++ ca-certificates \ && go get -d github.com/drakkan/sftpgo WORKDIR /go/src/github.com/drakkan/sftpgo -# uncomment the next line to get the latest stable version instead of the latest git -#RUN git checkout `git rev-list --tags --max-count=1` +ARG TAG +# Use --build-arg TAG=LATEST for latest tag. Use e.g. --build-arg TAG=0.9.6 for a specific tag. Otherwise HEAD (master) is built. +RUN git checkout $(if [ "${TAG}" = LATEST ]; then echo `git rev-list --tags --max-count=1`; elif [ -n "${TAG}" ]; then echo "${TAG}"; else echo HEAD; fi) RUN go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/utils.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/utils.date=`date -u +%FT%TZ`" -o /go/bin/sftpgo FROM alpine:latest @@ -28,4 +29,4 @@ VOLUME [ "/data", "/srv/sftpgo/config", "/srv/sftpgo/backups" ] EXPOSE 2022 8080 ENTRYPOINT ["/bin/entrypoint.sh"] -CMD ["serve"] \ No newline at end of file +CMD ["serve"] diff --git a/docker/sftpgo/alpine/README.md b/docker/sftpgo/alpine/README.md index 9a096762..14d0e588 100644 --- a/docker/sftpgo/alpine/README.md +++ b/docker/sftpgo/alpine/README.md @@ -13,7 +13,7 @@ sudo groupadd -g 1003 sftpgrp && \ # Edit sftpgo.json as you need -# Get and build SFTPGo image +# Get and build SFTPGo image (add --build-arg TAG=LATEST to build the latest tag or e.g. TAG=0.9.6 for a specific tag). git clone https://github.com/drakkan/sftpgo.git && \ cd sftpgo && \ sudo docker build -t sftpgo docker/sftpgo/alpine/ @@ -49,4 +49,4 @@ Several images can be run with different parameters. ### Custom systemd script An example of systemd script is present [here](sftpgo.service), with `Environment` parameter to set `PUID` and `GUID` -`WorkingDirectory` parameter must be exist with one file in this directory like `sftpgo-${PUID}.env` corresponding to the variable file for SFTPGo instance. \ No newline at end of file +`WorkingDirectory` parameter must be exist with one file in this directory like `sftpgo-${PUID}.env` corresponding to the variable file for SFTPGo instance.