#
# Dockerfile for samba (without netbios)
#

FROM alpine:edge

RUN apk add --update \
    samba-common-tools \
    samba-client \
    samba-server \
    && rm -rf /var/cache/apk/*

ENV USER=samba-user
ENV UID=1000
ENV GID=1000

RUN addgroup --gid ${GID} ${USER}

RUN adduser \
    --disabled-password \
    --gecos "" \
    --home "$(pwd)" \
    --ingroup "$USER" \
    --no-create-home \
    --uid "$UID" \
    "$USER"

# Read password from file and generate passwords (.pw just plain file)

ADD .pw /

RUN echo -ne "`cat /.pw`\n`cat /.pw`\n" | passwd ${USER}
RUN echo -ne "`cat /.pw`\n`cat /.pw`\n" | smbpasswd -a ${USER}
#RUN (cat /.pw ; cat /.pw) | passwd ${USER}
#RUN (cat /.pw ; cat /.pw) | smbpasswd -a ${USER}
RUN rm .pw

EXPOSE 445/tcp
#EXPOSE 139/tcp

ENTRYPOINT ["smbd", "--foreground", "--debug-stdout", "--no-process-group"]
#ENTRYPOINT ["tail", "-f", "/dev/null"]