Dockerfile: minor changes

This commit is contained in:
Nicola Murino 2020-10-05 16:31:22 +02:00
parent 7b76b51314
commit 8222baa7ed
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -18,7 +18,7 @@ COPY . .
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
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`" -v -o sftpgo
FROM alpine:3.12
@ -31,7 +31,7 @@ SHELL ["/bin/bash", "-c"]
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-424546457
RUN test ! -e /etc/nsswitch.conf && echo 'hosts: files dns' > /etc/nsswitch.conf
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo/{backups,data,credentials,host_keys} /srv/sftpgo/web
RUN mkdir -p /etc/sftpgo /var/lib/sftpgo /usr/share/sftpgo
RUN addgroup -g 1000 -S sftpgo
RUN adduser -u 1000 -h /var/lib/sftpgo -s /sbin/nologin -G sftpgo -S -D -H sftpgo
@ -42,23 +42,25 @@ RUN apk add --update --no-cache rsync git mailcap
# 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
ENV SFTPGO_HTTPD__TEMPLATES_PATH=/usr/share/sftpgo/templates
ENV SFTPGO_HTTPD__STATIC_FILES_PATH=/usr/share/sftpgo/static
# Sane defaults, but users should still be able to override this from env vars
ENV SFTPGO_DATA_PROVIDER__USERS_BASE_DIR=/var/lib/sftpgo/data
ENV SFTPGO_DATA_PROVIDER__USERS_BASE_DIR=/var/lib/sftpgo/users
ENV SFTPGO_DATA_PROVIDER__CREDENTIALS_PATH=/var/lib/sftpgo/credentials
ENV SFTPGO_HTTPD__BACKUPS_PATH=/var/lib/sftpgo/backups
ENV SFTPGO_SFTPD__HOST_KEYS=/var/lib/sftpgo/host_keys/id_rsa,/var/lib/sftpgo/host_keys/id_ecdsa
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/templates /usr/share/sftpgo/templates
COPY --from=builder /workspace/static /usr/share/sftpgo/static
COPY --from=builder /workspace/sftpgo /usr/local/bin/
RUN sed -i "s|sftpgo.db|/var/lib/sftpgo/sftpgo.db|" /etc/sftpgo/sftpgo.json
RUN chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo/web
RUN chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo
RUN chmod 750 /etc/sftpgo /var/lib/sftpgo
RUN chmod 640 /etc/sftpgo/sftpgo.json
USER sftpgo