How to run an sh script in docker file?

When running a sh script in docker file, i got the following error:

./upload.sh: 5: ./upload.sh: sudo: not found ./upload.sh: 21:
./upload.sh: Bad substitution

sudo chmod 755 upload.sh # line 5
version=$(git rev-parse --short HEAD)
echo "version $version"
echo "Uploading file"

for path in $(find public/files -name "*.txt"); do
  echo "path $path"
  WORDTOREMOVE="public/" 
  echo "WORDTOREMOVE $WORDTOREMOVE"
  # cause of the error
  newpath=${path//$WORDTOREMOVE/} # Line 21
  echo "new path $path"
  url=http://localhost:3000/${newpath}
  ...
  echo "Uploading file"
  ...
done

DockerFile

FROM node:10-slim

EXPOSE 3000 4001


WORKDIR /prod/code
...
COPY . .

RUN ./upload.sh
RUN npm run build
CMD ./DockerRun.sh

Any idea?

Source: StackOverflow