###
### Build Variables
###
FROM localhost/debian:latest

# deploy options
# -p (port) and -v (volume) both go host:container
LABEL config_default="\
-p 9045:445 \
-v /srv/vol/samba/data:/vol/data \
-v /srv/vol/samba/media:/vol/media \
-v /srv/vol/samba/files:/vol/files"

# uid that the files owner user should have
ARG FILESUID=5000

###
### General Setup
###

# install packages we want
RUN apt update -y && apt install -y samba

# create gitea user with file owner UID
RUN addgroup --gid $FILESUID files && \
    adduser files --ingroup files --uid $FILESUID --disabled-password --gecos "Files Owner" --shell /usr/sbin/nologin --no-create-home

RUN mkdir /vol && chown -R files:files /vol

# copy our custom scripts
COPY assets/bin/ /usr/local/bin/

RUN ls -A /home

# replace home with symlink
RUN cd / && rmdir home && ln -s /vol/files home

###
### NMBD
###

# disable NMBD
RUN systemctl disable nmbd

###
### SMBD
###

# copy samba config
COPY assets/smb.conf /etc/samba/smb.conf