2020-10-08 19:43:13 +00:00
|
|
|
FROM golang:1.15-alpine AS builder
|
|
|
|
|
|
|
|
ENV GOFLAGS="-mod=readonly"
|
|
|
|
|
|
|
|
RUN apk add --update --no-cache bash ca-certificates curl git gcc g++
|
|
|
|
|
|
|
|
RUN mkdir -p /workspace
|
|
|
|
WORKDIR /workspace
|
|
|
|
|
|
|
|
ARG GOPROXY
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
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 $(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 mailcap
|
|
|
|
|
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
|
|
|
|
# set up nsswitch.conf for Go's "netgo" implementation
|
|
|
|
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-424546457
|
|
|
|
RUN test ! -e /etc/nsswitch.conf && echo 'hosts: files dns' > /etc/nsswitch.conf
|
|
|
|
|
2020-10-14 05:46:36 +00:00
|
|
|
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo /usr/share/sftpgo /srv/sftpgo
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2020-10-09 18:25:42 +00:00
|
|
|
RUN addgroup -g 1000 -S sftpgo && \
|
|
|
|
adduser -u 1000 -h /var/lib/sftpgo -s /sbin/nologin -G sftpgo -S -D -H sftpgo
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
# Install some optional packages used by SFTPGo features
|
|
|
|
RUN apk add --update --no-cache rsync git
|
|
|
|
|
|
|
|
COPY --from=builder /workspace/sftpgo.json /etc/sftpgo/sftpgo.json
|
|
|
|
COPY --from=builder /workspace/templates /usr/share/sftpgo/templates
|
|
|
|
COPY --from=builder /workspace/static /usr/share/sftpgo/static
|
|
|
|
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
|
|
|
|
ENV SFTPGO_HTTPD__STATIC_FILES_PATH=/usr/share/sftpgo/static
|
|
|
|
|
|
|
|
# Modify the default configuration file
|
|
|
|
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 && \
|
|
|
|
sed -i "s|\"bind_address\": \"127.0.0.1\",|\"bind_address\": \"\",|" /etc/sftpgo/sftpgo.json
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2020-11-06 09:18:29 +00:00
|
|
|
RUN chown -R sftpgo:sftpgo /etc/sftpgo && chown sftpgo:sftpgo /var/lib/sftpgo /srv/sftpgo
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2020-10-14 05:46:36 +00:00
|
|
|
WORKDIR /var/lib/sftpgo
|
2020-10-18 17:18:51 +00:00
|
|
|
USER 1000:1000
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2020-10-14 05:46:36 +00:00
|
|
|
VOLUME [ "/var/lib/sftpgo", "/srv/sftpgo" ]
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
CMD sftpgo serve
|