Browse Source

Add a version build arg to the debian Dockerfile.

Henrik Lundahl 5 years ago
parent
commit
fd9b3c2767
2 changed files with 13 additions and 5 deletions
  1. 4 3
      docker/sftpgo/debian/Dockerfile
  2. 9 2
      docker/sftpgo/debian/README.md

+ 4 - 3
docker/sftpgo/debian/Dockerfile

@@ -3,8 +3,9 @@ FROM golang:latest as buildenv
 LABEL maintainer="nicola.murino@gmail.com"
 LABEL maintainer="nicola.murino@gmail.com"
 RUN go get -d github.com/drakkan/sftpgo
 RUN go get -d github.com/drakkan/sftpgo
 WORKDIR /go/src/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
 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
 # 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}
 ENV SFTPGO_HTTPD__BACKUPS_PATH=${BACKUPS_DIR}
 
 
 ENTRYPOINT ["sftpgo"]
 ENTRYPOINT ["sftpgo"]
-CMD ["serve"]
+CMD ["serve"]

+ 9 - 2
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" .
 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
 ```bash
 sudo mkdir -p /srv/sftpgo/data /srv/sftpgo/config /srv/sftpgo/backups
 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
 ```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
 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
-```
+```