Browse Source

Dockerfile: add a FEATURES build arg

This ARG allows to disable some optional features and it might be
useful if you build the image yourself
Nicola Murino 4 years ago
parent
commit
eed61ac510
2 changed files with 12 additions and 6 deletions
  1. 8 3
      Dockerfile
  2. 4 3
      pkgs/build.sh

+ 8 - 3
Dockerfile

@@ -14,16 +14,21 @@ RUN go mod download
 
 ARG COMMIT_SHA
 
+# This ARG allows to disable some optional features and it might be useful if you build the image yourself.
+# For example you can disable S3 and GCS support like this:
+# --build-arg FEATURES=nos3,nogcs
+ARG FEATURES
+
 COPY . .
 
 RUN set -xe && \
     export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --dirty)} && \
-    go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -v -o sftpgo
+    go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -v -o sftpgo
 
 
 FROM alpine:3.12
 
-RUN apk add --update --no-cache ca-certificates tzdata bash
+RUN apk add --update --no-cache ca-certificates tzdata bash mailcap
 
 SHELL ["/bin/bash", "-c"]
 
@@ -37,7 +42,7 @@ RUN addgroup -g 1000 -S sftpgo
 RUN adduser -u 1000 -h /var/lib/sftpgo -s /sbin/nologin -G sftpgo -S -D -H sftpgo
 
 # Install some optional packages used by SFTPGo features
-RUN apk add --update --no-cache rsync git mailcap
+RUN apk add --update --no-cache rsync git
 
 # Override some configuration details
 ENV SFTPGO_CONFIG_DIR=/etc/sftpgo

+ 4 - 3
pkgs/build.sh

@@ -40,9 +40,10 @@ maintainer: "Nicola Murino <nicola.murino@gmail.com>"
 provides:
   - sftpgo
 description: |
-  SFTPGo is a fully featured and highly configurable
-    SFTP server with optional FTP/S and WebDAV support.
-    It can serve local filesystem, S3, GCS
+  Fully featured and highly configurable SFTP server.
+    SFTPGo has optional FTP/S and WebDAV support.
+    It can serve local filesystem, S3 (Compatible) Object Storages
+    and Google Cloud Storage
 vendor: "SFTPGo"
 homepage: "https://github.com/drakkan/sftpgo"
 license: "GPL-3.0"