nginx: invalid option: "off" and entrypoint.sh: : Permission denied

I am creating build using Dockerfile and then deploying that build/image via jenkins job but container status is "CrashLoopBackOff" and when I am checking the logs, below error occurs..

Error:-

nginx: invalid option: "off"
/etc/nginx/entrypoint.sh: 5: /etc/nginx/entrypoint.sh: : Permission denied 

Note:- Full permission given to entrypoint.sh. (check the dockerfile)

Dockerfile:-

FROM node:12.18.4-alpine AS BUILD_IMAGE
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

COPY package.json .
COPY package-lock.json .
COPY .npmrc .
RUN npm install
COPY . .
RUN npm run build

FROM nginx:latest
RUN apt-get update
RUN apt-get -y install sudo
COPY --from=BUILD_IMAGE /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY .build/envs/uat/env.js /app/uat/env.js
COPY .build/envs/prod/env.js /app/prod/env.js
COPY entrypoint.sh /etc/nginx/entrypoint.sh
RUN  sudo chmod 777 /etc/nginx/entrypoint.sh
RUN  sudo nginx -t
RUN  ls -lrt /etc/nginx/

EXPOSE 80
ENTRYPOINT ["/etc/nginx/entrypoint.sh"]
# replace ENVIRONMENT with uat, prod
CMD ["ENVIRONMENT"]

entrypoint.sh file:-

#!/bin/sh
set -e

if [ "$1" = 'uat' ]; then
    "$(cp /app/uat/env.js /usr/share/nginx/html && nginx -g daemon off;)"
elif [ "$1" = 'prod' ]; then
    "$(cp /app/prod/env.js /usr/share/nginx/html && nginx -g daemon off; )"
fi

Error:-

Source: Docker Questions