FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Denver

RUN apt-get update && apt-get install -y --no-install-recommends tzdata samba krb5-user libpam-krb5 libnss-winbind libpam-winbind iputils-ping && \
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
    dpkg-reconfigure --frontend noninteractive tzdata && \
    rm -rf /var/lib/apt/lists/*

COPY smb.conf /etc/samba/smb.conf
COPY krb5.conf /etc/krb5.conf
COPY entrypoint.sh /entrypoint.sh

# Validate the smb.conf file
RUN testparm -s /etc/samba/smb.conf

# Create the directory and change its ownership and permissions
RUN mkdir -p /mnt/example && chown nobody:nogroup /mnt/example && chmod 777 /mnt/example

# Set executable permissions for the entrypoint script
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]