2020-10-08 19:43:13 +00:00
|
|
|
FROM golang:1.15 as builder
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
ENV GOFLAGS="-mod=readonly"
|
|
|
|
|
|
|
|
RUN mkdir -p /workspace
|
|
|
|
WORKDIR /workspace
|
|
|
|
|
|
|
|
ARG GOPROXY
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
|
|
|
2020-10-04 22:17:17 +00:00
|
|
|
ARG COMMIT_SHA
|
|
|
|
|
2020-10-07 18:04:02 +00:00
|
|
|
# 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
|
|
|
|
|
2020-10-04 21:42:33 +00:00
|
|
|
COPY . .
|
|
|
|
|
2020-10-04 22:17:17 +00:00
|
|
|
RUN set -xe && \
|
|
|
|
export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --dirty)} && \
|
2020-10-07 18:04:02 +00:00
|
|
|
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
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-08 19:43:13 +00:00
|
|
|
FROM debian:buster-slim
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-08 19:43:13 +00:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates mime-support && apt-get clean
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
|
2020-10-05 14:31:22 +00:00
|
|
|
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo /usr/share/sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-09 18:25:42 +00:00
|
|
|
RUN groupadd --system -g 1000 sftpgo && \
|
|
|
|
useradd --system --gid sftpgo --no-create-home \
|
2020-10-08 19:43:13 +00:00
|
|
|
--home-dir /var/lib/sftpgo --shell /usr/sbin/nologin \
|
|
|
|
--comment "SFTPGo user" --uid 1000 sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-06 16:03:55 +00:00
|
|
|
# Install some optional packages used by SFTPGo features
|
2020-10-08 19:43:13 +00:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y git rsync && apt-get clean
|
2020-10-06 16:03:55 +00:00
|
|
|
|
2020-10-04 21:42:33 +00:00
|
|
|
# Override some configuration details
|
|
|
|
ENV SFTPGO_CONFIG_DIR=/etc/sftpgo
|
|
|
|
ENV SFTPGO_LOG_FILE_PATH=""
|
2020-10-05 14:31:22 +00:00
|
|
|
ENV SFTPGO_HTTPD__TEMPLATES_PATH=/usr/share/sftpgo/templates
|
|
|
|
ENV SFTPGO_HTTPD__STATIC_FILES_PATH=/usr/share/sftpgo/static
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
# Sane defaults, but users should still be able to override this from env vars
|
2020-10-05 14:31:22 +00:00
|
|
|
ENV SFTPGO_DATA_PROVIDER__USERS_BASE_DIR=/var/lib/sftpgo/users
|
2020-10-05 12:47:58 +00:00
|
|
|
ENV SFTPGO_DATA_PROVIDER__CREDENTIALS_PATH=/var/lib/sftpgo/credentials
|
2020-10-05 09:06:01 +00:00
|
|
|
ENV SFTPGO_HTTPD__BACKUPS_PATH=/var/lib/sftpgo/backups
|
2020-10-05 09:14:34 +00:00
|
|
|
ENV SFTPGO_SFTPD__HOST_KEYS=/var/lib/sftpgo/host_keys/id_rsa,/var/lib/sftpgo/host_keys/id_ecdsa
|
2020-10-06 11:59:31 +00:00
|
|
|
ENV SFTPGO_HTTPD__BIND_ADDRESS=""
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
COPY --from=builder /workspace/sftpgo.json /etc/sftpgo/sftpgo.json
|
2020-10-05 14:31:22 +00:00
|
|
|
COPY --from=builder /workspace/templates /usr/share/sftpgo/templates
|
|
|
|
COPY --from=builder /workspace/static /usr/share/sftpgo/static
|
2020-10-04 21:42:33 +00:00
|
|
|
COPY --from=builder /workspace/sftpgo /usr/local/bin/
|
|
|
|
|
2020-10-05 13:12:10 +00:00
|
|
|
RUN sed -i "s|sftpgo.db|/var/lib/sftpgo/sftpgo.db|" /etc/sftpgo/sftpgo.json
|
|
|
|
|
2020-10-06 11:59:31 +00:00
|
|
|
RUN chown -R sftpgo:sftpgo /etc/sftpgo && chown sftpgo:sftpgo /var/lib/sftpgo && \
|
|
|
|
chmod 640 /etc/sftpgo/sftpgo.json && \
|
|
|
|
chmod 750 /etc/sftpgo /var/lib/sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
USER sftpgo
|
|
|
|
|
2020-10-05 10:43:10 +00:00
|
|
|
VOLUME /var/lib/sftpgo
|
|
|
|
|
2020-10-04 21:42:33 +00:00
|
|
|
CMD sftpgo serve
|