we are using google cloud run and mounted our code logs to a filestore using NFS , my problem is if the tomcat code log is deleted accidently the logs from filestore it is not generated again automatically.
My Dockerfile
FROM tomcat:8.5.77-jre8-openjdk-slim-buster
RUN apt-get update -y && apt-get install -y
nfs-common
netbase
&& apt-get clean
RUN mkdir /usr/local/tomcat/webapps/router
ADD . /usr/local/tomcat/webapps/router
Set fallback mount directory
ENV MNT_DIR /usr/local/tomcat/webapps/router/logs
WORKDIR /usr/local/tomcat/webapps/router
RUN chmod +x /usr/local/tomcat/webapps/router/run.sh
Use tini to manage zombie processes and signal forwarding ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini
/tini RUN chmod +x /tini ENTRYPOINT ["/tini", "--"]
Pass the startup script as arguments to tini
CMD ["/usr/local/tomcat/webapps/router/run.sh"]
ENV PORT=8080
EXPOSE 8080 EXPOSE 2049 EXPOSE 111
My script file
#!/bin/bash
set -eo pipefail
Create mount directory or mount point for container service.
chmod -R 777 /usr/local/tomcat/webapps/router/logs
mount --verbose -t nfs -o vers=3 -o nolock 10.67.157.122:/filestore_vol1/test/testing/logss
/usr/local/tomcat/webapps/router/logs
echo "Mounting completed."
show the mount process
showmount -e 10.67.157.x
check which dir has mounted to which dir of filestore.
df -h
create a file at mount directory or mount point to be shown at
touch /$MNT_DIR/dragon.js
chmod 777 /$MNT_DIR/dragon.js
touch /usr/local/tomcat/webapps/router/logs/newdragon.js
/usr/local/tomcat/bin/catalina.sh run
Exit immediately when one of the background processes terminate.
wait -n