add build image mysql del
parent
e0020a3aa8
commit
fbb13501b9
|
@ -0,0 +1,8 @@
|
||||||
|
FROM mysql:8.0.33-debian
|
||||||
|
|
||||||
|
LABEL MAINTAINER='beaconfire'
|
||||||
|
|
||||||
|
ENV HOST="" PORT="" MYSQL_USER="" MYSQL_PASSWORD="" REMAIN_DAYS=""
|
||||||
|
COPY entrypoint.sh /usr/local/bin
|
||||||
|
|
||||||
|
CMD [ "/usr/local/bin/entrypoint.sh" ]
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo -ne "[client]\nhost=${HOST}\nport=${PORT}\nuser=${MYSQL_USER}\npassword=${MYSQL_PASSWORD}\n" > /etc/my.cnf
|
||||||
|
|
||||||
|
create_time=$(mysql --defaults-extra-file=/etc/my.cnf -e "SELECT NOW() - INTERVAL '$REMAIN_DAYS' DAY"|egrep '[0-9]{4}')
|
||||||
|
if [ -z "$create_time" ]; then
|
||||||
|
echo "Failed to retrieve create_time. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Deleting records older than: $create_time"
|
||||||
|
mysql --defaults-extra-file=/etc/my.cnf -e "delete * from question.code_run where create_time <'${create_time}'"
|
Loading…
Reference in New Issue