diff --git a/docker/sftpgo/debian/Dockerfile b/docker/sftpgo/debian/Dockerfile index 0e2a8795..7c8fae41 100644 --- a/docker/sftpgo/debian/Dockerfile +++ b/docker/sftpgo/debian/Dockerfile @@ -3,8 +3,9 @@ FROM golang:latest as buildenv LABEL maintainer="nicola.murino@gmail.com" RUN 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 sftpgo # now define the run environment @@ -69,4 +70,4 @@ ENV SFTPGO_DATA_PROVIDER__USERS_BASE_DIR=${DATA_DIR} ENV SFTPGO_HTTPD__BACKUPS_PATH=${BACKUPS_DIR} ENTRYPOINT ["sftpgo"] -CMD ["serve"] \ No newline at end of file +CMD ["serve"] diff --git a/docker/sftpgo/debian/README.md b/docker/sftpgo/debian/README.md index 754435b2..c1452c11 100644 --- a/docker/sftpgo/debian/README.md +++ b/docker/sftpgo/debian/README.md @@ -8,7 +8,14 @@ You can build the container image using `docker build`, for example: docker build -t="drakkan/sftpgo" . ``` -now create the required folders on the host system, for example: +This will build master of github.com/drakkan/sftpgo. To build the latest tag you can add `--build-arg TAG=LATEST` +and to build a specific tag you can use for example `TAG=0.9.6`, like this: + +```bash +docker build -t="drakkan/sftpgo" --build-arg TAG=0.9.6 . +``` + +Now create the required folders on the host system, for example: ```bash sudo mkdir -p /srv/sftpgo/data /srv/sftpgo/config /srv/sftpgo/backups @@ -36,4 +43,4 @@ and finally you can run the image using something like this: ```bash docker rm sftpgo && docker run --name sftpgo -p 8080:8080 -p 2022:2022 --mount type=bind,source=/srv/sftpgo/data,target=/app/data --mount type=bind,source=/srv/sftpgo/config,target=/app/config --mount type=bind,source=/srv/sftpgo/backups,target=/app/backups drakkan/sftpgo -``` \ No newline at end of file +```