You can add something like this to remove any user with same gid if present.
# Check if any user already exist with same GID and if exist delete it RUN awk -v gid="${USER_GID}" -F':' '$4 == gid {print $1}' /etc/passwd | xargs -r userdel -r