FROM eclipse-mosquitto:2

arg UID=1000
arg GID=1000
arg USER=unicorn

RUN if [ ${USER} != "root" ]; then \
        apk add shadow && \
        groupadd -f -g ${GID} ${USER} && \
        useradd -m -g ${USER} -u ${UID} ${USER}; \
    fi

RUN chown -R ${USER}:${USER} /mosquitto

USER ${USER}