Files
samba/Dockerfile
2026-01-07 16:45:26 +03:00

80 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 = 1
aio write size = 1
use sendfile = yes
getwd cache = yes
min receivefile size = 16384
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
vfs objects = catia recycle
# 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
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"]