2020-10-04 21:42:33 +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
|
|
|
|
|
2020-10-04 22:17:17 +00:00
|
|
|
ARG COMMIT_SHA
|
|
|
|
|
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)} && \
|
|
|
|
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`" -o sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:3.12
|
|
|
|
|
|
|
|
RUN apk add --update --no-cache ca-certificates tzdata bash
|
|
|
|
|
|
|
|
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-05 12:47:58 +00:00
|
|
|
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo/{backups,data,credentials,host_keys} /srv/sftpgo/web
|
2020-10-04 21:42:33 +00:00
|
|
|
|
|
|
|
RUN addgroup -g 1000 -S sftpgo
|
2020-10-05 10:46:09 +00:00
|
|
|
RUN adduser -u 1000 -h /var/lib/sftpgo -s /sbin/nologin -G sftpgo -S -D -H sftpgo
|
2020-10-04 21:42:33 +00:00
|
|
|
|
2020-10-05 10:50:01 +00:00
|
|
|
# Install some optional packages used by sftpgo features
|
|
|
|
RUN apk add --update --no-cache rsync git mailcap
|
|
|
|
|
2020-10-04 21:42:33 +00:00
|
|
|
# Override some configuration details
|
|
|
|
ENV SFTPGO_CONFIG_DIR=/etc/sftpgo
|
|
|
|
ENV SFTPGO_LOG_FILE_PATH=""
|
|
|
|
ENV SFTPGO_HTTPD__TEMPLATES_PATH=/srv/sftpgo/web/templates
|
|
|
|
ENV SFTPGO_HTTPD__STATIC_FILES_PATH=/srv/sftpgo/web/static
|
|
|
|
|
|
|
|
# Sane defaults, but users should still be able to override this from env vars
|
2020-10-05 09:08:40 +00:00
|
|
|
ENV SFTPGO_DATA_PROVIDER__USERS_BASE_DIR=/var/lib/sftpgo/data
|
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-04 21:42:33 +00:00
|
|
|
|
|
|
|
COPY --from=builder /workspace/sftpgo.json /etc/sftpgo/sftpgo.json
|
|
|
|
COPY --from=builder /workspace/templates /srv/sftpgo/web/templates
|
|
|
|
COPY --from=builder /workspace/static /srv/sftpgo/web/static
|
|
|
|
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-05 09:08:40 +00:00
|
|
|
RUN chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo/web
|
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
|