diff --git a/.dockerignore b/.dockerignore index f7f5a19..722125d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ * -!*.s6 +!s6/* diff --git a/Dockerfile b/Dockerfile index 40cad08..3a7f893 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,18 @@ FROM alpine:latest -ENV UID 1000 ENV USERNAME samba -ENV GID 1000 -ENV GROUP samba ENV PASSWORD password -ENV CONFIG /config/smb.conf +ENV UID 1000 +ENV GID 1000 -RUN set -xe \ - && apk add --update --no-progress samba-common-tools samba-server openssl \ - && rm -rf /var/cache/apk/* +RUN apk add --no-cache samba-server samba-common-tools openssl -ENV S6_VERSION 1.18.1.5 -RUN set -xe \ - && cd /tmp \ - && wget https://github.com/just-containers/s6-overlay/releases/download/v$S6_VERSION/s6-overlay-amd64.tar.gz \ - && wget https://github.com/just-containers/s6-overlay/releases/download/v$S6_VERSION/s6-overlay-amd64.tar.gz.sig \ - && apk add --update --no-progress --virtual gpg gnupg \ - && wget -q -O - https://keybase.io/justcontainers/key.asc | gpg --import \ - && gpg --verify /tmp/s6-overlay-amd64.tar.gz.sig /tmp/s6-overlay-amd64.tar.gz \ - && tar xzf s6-overlay-amd64.tar.gz -C / \ - && apk del gpg \ - && rm -rf /tmp/s6-overlay-amd64.tar.gz /tmp/s6-overlay-amd64.tar.gz.sig /root/.gnupg /var/cache/apk/* +ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-amd64.tar.gz /tmp/ +RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / -COPY run.s6 /etc/services.d/samba/run -COPY finish.s6 /etc/services.d/samba/finish +COPY s6/config.init /etc/cont-init.d/00-config +COPY s6/smbd.run /etc/services.d/smbd/run +COPY s6/nmbd.run /etc/services.d/nmbd/run EXPOSE 137/udp 138/udp 139/tcp 445/tcp diff --git a/example/docker-compose.yml b/example/docker-compose.yml index bd6bd1c..443dddb 100644 --- a/example/docker-compose.yml +++ b/example/docker-compose.yml @@ -3,7 +3,7 @@ samba: volumes: # You must provide a Samba config file - - ./smb.conf:/config/smb.conf + - ./smb.conf:/etc/samba/smb.conf # Shares - ~/projects:/mnt/projects @@ -19,8 +19,6 @@ samba: - USERNAME=joe - PASSWORD=samba - # Defaults - - UID=1000 - - GID=1000 - - GROUP=samba - - CONFIG=/config/smb.conf + # Uncomment to override defaults + # - UID=1000 + # - GID=1000 diff --git a/finish.s6 b/finish.s6 deleted file mode 100644 index b6531b3..0000000 --- a/finish.s6 +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/execlineb -S0 - -s6-svscanctl -t /var/run/s6/services diff --git a/run.s6 b/run.s6 deleted file mode 100644 index dd727c3..0000000 --- a/run.s6 +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/with-contenv sh - -if [ ! -f "${CONFIG}" ]; then - echo "ERROR: You must pass though a Samba config file at \"${CONFIG}\" or change \$CONFIG to the config file path" - exit 1 -fi - -addgroup -g ${GID} ${GROUP} > /dev/null 2&>1 -adduser -S -G ${GROUP} -u ${UID} -H -D ${USERNAME} -echo "${PASSWORD}" | tee - | smbpasswd -s -c "${CONFIG}" -a ${USERNAME} - -nmbd --foreground --log-stdout --configfile="${CONFIG}" & -smbd --foreground --log-stdout --configfile="${CONFIG}" diff --git a/s6/config.init b/s6/config.init new file mode 100644 index 0000000..f2fc381 --- /dev/null +++ b/s6/config.init @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv sh + +addgroup -g $GID samba > /dev/null 2&>1 +adduser -S -G samba -u $UID -H -D $USERNAME +echo "$PASSWORD" | tee - | smbpasswd -s -c /etc/samba/smb.conf -a $USERNAME diff --git a/s6/nmbd.run b/s6/nmbd.run new file mode 100644 index 0000000..5cf9d82 --- /dev/null +++ b/s6/nmbd.run @@ -0,0 +1,3 @@ +#!/usr/bin/execlineb -P + +nmbd --foreground --log-stdout diff --git a/s6/smbd.run b/s6/smbd.run new file mode 100644 index 0000000..2a9372e --- /dev/null +++ b/s6/smbd.run @@ -0,0 +1,3 @@ +#!/usr/bin/execlineb -P + +smbd --foreground --log-stdout