I have build my application using the docker file on google gcp. I am trying to run my web application build/run on tomcat.
from ubuntu
COPY /mnt/opt/apache-tomcat-9.0.5/ /mnt/opt/apache-tomcat-9.0.5/
RUN apt update
COPY cronjob /etc/cron.d/cronjob
RUN chmod 0644 /etc/cron.d/cronjob
RUN crontab /etc/cron.d/cronjob
ENV CATALINA_HOME /mnt/opt/apache-tomcat-9.0.5
ENV PATH $CATALINA_HOME/bin:$PATH
ENV PATH /mnt/opt/java/jdk-10.0.1/bin:$PATH
ENV PORT 80
ENV HOST 0.0.0.0
EXPOSE 80 443
CMD /mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh run
#ENTRYPOINT ["/mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh", "run"]
Using the following approach to deploy on google cloud run.
docker tag miniimagesvideos gcr.io/serious-bearing-358305/miniimagesvideos
docker push gcr.io/serious-bearing-358305/miniimagesvideos
gcloud run deploy --image=gcr.io/serious-bearing-358305/miniimagesvideos --port=80 --region=asia-southeast2 --allow-unauthenticated platform=managed --command=/mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh
I keep getting error mentioned in the subject line
It seem container shuts down immediately while trying to deploy on Google Cloud run. Whereas, there is no issue while trying to run docker container on a Google VM. Is there any additional configuration required for Google cloud run. Why tomcat is not able to run on Google cloud run?
The following combination worked on Google Cloud run.
1. openjdk version "11.0.18"
2. apache-tomcat-10.1.8
Please note i was required to implement some additional steps for my app to migrate from 9.0.75 to 10.1.8. These are trivial changes to migrate from tomcat 9.x to 10.x.
SSL Connector needs an explicit tag for SSLHostconfig
<SSLHostConfig hostName="test.test"
protocols="TLSv1.2">
<Certificate certificateFile="/etc/letsencrypt/archive/miniimagesvideos.com/cert2.pem" certificateKeyFile="/etc/letsencrypt/archive/miniimagesvideos.com/privkey2.pem" certificateChainFile="/etc/letsencrypt/archive/miniimagesvideos.com/chain2.pem" />
</SSLHostConfig>
</Connector>
In the context.xml the following needs to be added
<Loader jakartaConverter="TOMCAT" />
Conclusion After multiple troubleshooting, i could reach to the following conclusion
Google cloud run execute Catalina.sh in a manner that the tomcat is running the background. Log indicate "Tomcat Started" and then there is another log of "container exited".
However, for 10.X version tomcat is kicked off as a foreground process.