2024-05-25 14:53:13 +00:00
|
|
|
FROM golang:1.22-alpine3.20 AS builder
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
ENV GOFLAGS="-mod=readonly"
|
|
|
|
|
2023-10-13 13:55:27 +00:00
|
|
|
RUN apk -U upgrade --no-cache && apk add --update --no-cache bash ca-certificates curl git gcc g++
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
RUN mkdir -p /workspace
|
|
|
|
WORKDIR /workspace
|
|
|
|
|
|
|
|
ARG GOPROXY
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
2024-09-06 18:12:37 +00:00
|
|
|
RUN go mod download && go mod verify
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
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 && \
|
2022-09-08 11:44:14 +00:00
|
|
|
export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --abbrev=8 --dirty)} && \
|
2022-07-24 14:18:54 +00:00
|
|
|
go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${COMMIT_SHA} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -v -o sftpgo
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2024-05-25 14:51:48 +00:00
|
|
|
FROM alpine:3.20
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2022-03-23 10:35:23 +00:00
|
|
|
# Set to "true" to install jq and the optional git and rsync dependencies
|
2021-02-07 20:49:04 +00:00
|
|
|
ARG INSTALL_OPTIONAL_PACKAGES=false
|
|
|
|
|
2023-10-13 13:55:27 +00:00
|
|
|
RUN apk -U upgrade --no-cache && apk add --update --no-cache ca-certificates tzdata mailcap
|
2020-10-08 19:43:13 +00:00
|
|
|
|
2022-03-23 10:35:23 +00:00
|
|
|
RUN if [ "${INSTALL_OPTIONAL_PACKAGES}" = "true" ]; then apk add --update --no-cache jq git rsync; 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-08 19:43:13 +00:00
|
|
|
|
2020-10-09 18:25:42 +00:00
|
|
|
RUN addgroup -g 1000 -S sftpgo && \
|
2020-11-10 22:11:57 +00:00
|
|
|
adduser -u 1000 -h /var/lib/sftpgo -s /sbin/nologin -G sftpgo -S -D -H -g "SFTPGo user" sftpgo
|
2020-10-08 19:43:13 +00:00
|
|
|
|
|
|
|
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
|
2021-11-21 08:32:51 +00:00
|
|
|
COPY --from=builder /workspace/openapi /usr/share/sftpgo/openapi
|
2020-10-08 19:43:13 +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=""
|
|
|
|
|
|
|
|
# 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-08 19:43:13 +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-08 19:43:13 +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-08 19:43:13 +00:00
|
|
|
|
2020-11-10 22:11:57 +00:00
|
|
|
CMD ["sftpgo", "serve"]
|