-
-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is possible thanks to a new project sponsor Signed-off-by: Nicola Murino <[email protected]>
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
FROM golang:1.21-bookworm as builder | ||
|
||
ENV CGO_ENABLED=0 GOFLAGS="-mod=readonly" | ||
|
||
RUN apt-get update && apt-get -y upgrade && apt-get install --no-install-recommends -y media-types openssh-server && rm -rf /var/lib/apt/lists/* | ||
|
||
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 this variant we disable SQLite support since it requires CGO and so a C runtime which is not installed | ||
# in distroless/static-* images | ||
ARG FEATURES | ||
|
||
COPY . . | ||
|
||
RUN set -xe && \ | ||
export COMMIT_SHA=${COMMIT_SHA:-$(git describe --always --abbrev=8 --dirty)} && \ | ||
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 | ||
|
||
# Modify the default configuration file | ||
RUN sed -i 's|"users_base_dir": "",|"users_base_dir": "/srv/sftpgo/data",|' sftpgo.json && \ | ||
sed -i 's|"backups"|"/srv/sftpgo/backups"|' sftpgo.json && \ | ||
sed -i 's|"sqlite"|"bolt"|' sftpgo.json | ||
|
||
RUN mkdir /etc/sftpgo /var/lib/sftpgo /srv/sftpgo | ||
|
||
FROM gcr.io/distroless/static-debian12 | ||
|
||
COPY --from=builder --chown=1000:1000 /etc/sftpgo /etc/sftpgo | ||
COPY --from=builder --chown=1000:1000 /srv/sftpgo /srv/sftpgo | ||
COPY --from=builder --chown=1000:1000 /var/lib/sftpgo /var/lib/sftpgo | ||
COPY --from=builder --chown=1000:1000 /workspace/sftpgo.json /etc/sftpgo/sftpgo.json | ||
COPY --from=builder --chown=1000:1000 /etc/ssh/moduli /etc/sftpgo/moduli | ||
COPY --from=builder /workspace/templates /usr/share/sftpgo/templates | ||
COPY --from=builder /workspace/static /usr/share/sftpgo/static | ||
COPY --from=builder /workspace/openapi /usr/share/sftpgo/openapi | ||
COPY --from=builder /workspace/sftpgo /usr/local/bin/ | ||
COPY --from=builder /etc/mime.types /etc/mime.types | ||
|
||
# Log to the stdout so the logs will be available using docker logs | ||
ENV SFTPGO_LOG_FILE_PATH="" | ||
# These env vars are required to avoid the following error when calling user.Current(): | ||
# unable to get the current user: user: Current requires cgo or $USER set in environment | ||
ENV USER=sftpgo | ||
ENV HOME=/var/lib/sftpgo | ||
|
||
WORKDIR /var/lib/sftpgo | ||
USER 1000:1000 | ||
|
||
CMD ["sftpgo", "serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters