Getting different results running python script through Dockerfile vs terminal within Container

I’m trying to containerise a service which listens to a Google PubSub queue of urls, processes the data using some ML models and uploads the results to a firestore DB.

Locally it works as expected, however when it comes to building and running the docker container I see some very strange behaviour. When I run the server through:

CMD ["python3", ""]

at the end of the Dockerfile, the script starts but doesn’t behave as expected. Some console warnings/startup stuff from packages are printed, but it immediately hangs before reaching any of my code. If I try a print statement before my imports it never shows.

What’s stranger is that if I enter the container and run the exact same command through the terminal it does exactly what I expect and starts the server. I made a little script to check the environments and when I run it through CMD and terminal they both show the same output.

Has anyone seen this before? Or is there any workaround that I can try? I’ve tried starting it through a .sh but it didn’t make any difference. I’ve spent around 2 days on this with no luck so any help would be appreciated. Here’s the Dockerfile