2022-03-18 20:52:00 +00:00
|
|
|
FROM golang:1.18-bullseye 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)} && \
|
2021-06-26 05:31:41 +00:00
|
|
|
go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -v -o sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2021-08-18 12:39:56 +00:00
|
|
|
FROM debian:bullseye-slim
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2022-03-22 16:29:14 +00:00
|
|
|
# Set to "true" to install the optional git and rsync dependencies
|
2021-02-07 20:49:04 +00:00
|
|
|
ARG INSTALL_OPTIONAL_PACKAGES=false
|
|
|
|
|
2021-09-07 19:04:46 +00:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates media-types && rm -rf /var/lib/apt/lists/*
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2022-03-22 16:29:14 +00:00
|
|
|
RUN if [ "${INSTALL_OPTIONAL_PACKAGES}" = "true" ]; then apt-get update && apt-get install --no-install-recommends -y git rsync && rm -rf /var/lib/apt/lists/*; fi
|
2021-02-07 20:49:04 +00:00
|
|
|
|
2021-02-10 18:04:06 +00:00
|
|
|
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo /usr/share/sftpgo /srv/sftpgo/data /srv/sftpgo/backups
|
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
|
|
|
|
|
|
|
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
|
2021-11-21 08:32:51 +00:00
|
|
|
COPY --from=builder /workspace/openapi /usr/share/sftpgo/openapi
|
2020-10-04 21:42:33 +00:00
|
|
|
COPY --from=builder /workspace/sftpgo /usr/local/bin/
|
|
|
|
|
2020-10-14 05:46:36 +00:00
|
|
|
# Log to the stdout so the logs will be available using docker logs
|
|
|
|
ENV SFTPGO_LOG_FILE_PATH=""
|
|
|
|
# templates and static paths are inside the container
|
|
|
|
ENV SFTPGO_HTTPD__TEMPLATES_PATH=/usr/share/sftpgo/templates
|
2021-10-02 20:25:41 +00:00
|
|
|
ENV SFTPGO_SMTP__TEMPLATES_PATH=/usr/share/sftpgo/templates
|
2020-10-14 05:46:36 +00:00
|
|
|
ENV SFTPGO_HTTPD__STATIC_FILES_PATH=/usr/share/sftpgo/static
|
2021-11-21 08:32:51 +00:00
|
|
|
ENV SFTPGO_HTTPD__OPENAPI_PATH=/usr/share/sftpgo/openapi
|
2020-10-14 05:46:36 +00:00
|
|
|
|
|
|
|
# Modify the default configuration file
|
2022-02-25 16:38:15 +00:00
|
|
|
RUN sed -i 's|"users_base_dir": "",|"users_base_dir": "/srv/sftpgo/data",|' /etc/sftpgo/sftpgo.json && \
|
|
|
|
sed -i 's|"backups"|"/srv/sftpgo/backups"|' /etc/sftpgo/sftpgo.json
|
2020-10-05 13:12:10 +00:00
|
|
|
|
2021-02-10 18:04:06 +00:00
|
|
|
RUN chown -R sftpgo:sftpgo /etc/sftpgo /srv/sftpgo && chown sftpgo:sftpgo /var/lib/sftpgo && chmod 700 /srv/sftpgo/backups
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-14 05:46:36 +00:00
|
|
|
WORKDIR /var/lib/sftpgo
|
2020-11-12 10:53:05 +00:00
|
|
|
USER 1000:1000
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-11-10 22:11:57 +00:00
|
|
|
CMD ["sftpgo", "serve"]
|