'how to run cron in dockerfile mySQL

I am new to dockerfile and basically I am trying to build a mysql image that runs a store proc every minute using cron and dockerFile content is shown below:

FROM mysql:5.7.16

ENV TZ Asia/Muscat

ENV http_proxy=http://000.000.00.1:8786/

ENV https_proxy=http://000.000.00.1:8786/

COPY I_Dump.sql /docker-entrypoint-initdb.d/

#Install Cron
RUN apt-get update
RUN apt-get -y install cron


# Add the cron job
RUN crontab -l | { cat; echo "* * * * * docker exec -t mysql mysql -uroot -proot -e "SELECT dummy.updatePublisherStatus()"; } | crontab -

# Run the command on container startup
CMD cron

When I run the command docker build -t mysqlinfocron . I get the following error:

   /bin/sh: 1: Syntax error: "(" unexpected (expecting "}")
The command '/bin/sh -c crontab -l | { cat; echo "* * * * * docker exec -t mysql mysql -uroot -proot -e "SELECT dummy.updatePublisherStatus()"; } | crontab -' returned a non-zero code: 2

I know my syntax is wrong but I don't know how to fix it, any feedback is most welcome?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source