- samba.sh: Add SMB_CONF constant, create set_config_option() to reduce duplication, replace deprecated egrep with grep -E, improve quoting - Dockerfile: Replace multiple echo commands with heredoc for readability, separate logical build stages - docker-compose.yml: Add healthcheck, improve formatting - .dockerignore: Extend exclusion list 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
82 lines
2.6 KiB
Docker
82 lines
2.6 KiB
Docker
ARG ALPINE_VERSION=3.21
|
|
FROM hub.docker.struchkov.dev/alpine:${ALPINE_VERSION}
|
|
|
|
LABEL maintainer="Struchkov Mark <mark@struchkov.dev>"
|
|
LABEL org.opencontainers.image.source="https://github.com/upagge/samba"
|
|
LABEL org.opencontainers.image.description="Samba file server with Time Machine support"
|
|
|
|
# Install packages and create samba user
|
|
RUN apk --no-cache --no-progress upgrade && \
|
|
apk --no-cache --no-progress add bash samba shadow tini tzdata && \
|
|
addgroup -S smb && \
|
|
adduser -S -D -H -h /tmp -s /sbin/nologin -G smb -g 'Samba User' smbuser
|
|
|
|
# Configure smb.conf
|
|
RUN file="/etc/samba/smb.conf" && \
|
|
# Modify existing options
|
|
sed -i 's|^;* *\(log file = \).*| \1/dev/stdout|' "$file" && \
|
|
sed -i 's|^;* *\(load printers = \).*| \1no|' "$file" && \
|
|
sed -i 's|^;* *\(printcap name = \).*| \1/dev/null|' "$file" && \
|
|
sed -i 's|^;* *\(printing = \).*| \1bsd|' "$file" && \
|
|
sed -i 's|^;* *\(unix password sync = \).*| \1no|' "$file" && \
|
|
sed -i 's|^;* *\(preserve case = \).*| \1yes|' "$file" && \
|
|
sed -i 's|^;* *\(short preserve case = \).*| \1yes|' "$file" && \
|
|
sed -i 's|^;* *\(default case = \).*| \1lower|' "$file" && \
|
|
sed -i '/Share Definitions/,$d' "$file" && \
|
|
# Append additional configuration
|
|
cat >> "$file" <<'EOF'
|
|
pam password change = yes
|
|
map to guest = bad user
|
|
usershare allow guests = yes
|
|
create mask = 0664
|
|
force create mode = 0664
|
|
directory mask = 0775
|
|
force directory mode = 0775
|
|
force user = smbuser
|
|
force group = smb
|
|
follow symlinks = yes
|
|
load printers = no
|
|
printing = bsd
|
|
printcap name = /dev/null
|
|
disable spoolss = yes
|
|
strict locking = no
|
|
aio read size = 0
|
|
aio write size = 0
|
|
vfs objects = catia fruit recycle streams_xattr
|
|
|
|
# Recycle bin
|
|
recycle:keeptree = yes
|
|
recycle:maxsize = 0
|
|
recycle:repository = .deleted
|
|
recycle:versions = yes
|
|
|
|
# Security
|
|
client ipc max protocol = SMB3
|
|
client ipc min protocol = SMB2_10
|
|
client max protocol = SMB3
|
|
client min protocol = SMB2_10
|
|
server max protocol = SMB3
|
|
server min protocol = SMB2_10
|
|
|
|
# Time Machine
|
|
fruit:delete_empty_adfiles = yes
|
|
fruit:time machine = yes
|
|
fruit:veto_appledouble = no
|
|
fruit:wipe_intentionally_left_blank_rfork = yes
|
|
|
|
EOF
|
|
|
|
# Cleanup
|
|
RUN rm -rf /tmp/*
|
|
|
|
COPY samba.sh /usr/bin/
|
|
|
|
EXPOSE 137/udp 138/udp 139 445
|
|
|
|
HEALTHCHECK --interval=60s --timeout=15s --start-period=10s --retries=3 \
|
|
CMD smbclient -L \\localhost -U % -m SMB3 || exit 1
|
|
|
|
VOLUME ["/etc", "/var/cache/samba", "/var/lib/samba", "/var/log/samba", "/run/samba"]
|
|
|
|
ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/samba.sh"]
|