Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
How to only run certain lines of code in production on google cloud run?

I'm writing FastAPI services and deploying to Google Cloud Run.

I would like to run certain code on my laptop, certain code on cloud run, etc. I would like to customize the code based on the environment it is run in.

How can I know if I am in a container, google cloud run, my Mac laptop, vscode spaces, GitHub actions...How can I add that information to debug variable?

    debug,cloud,laptop,vcode = Environment()
    if debug:
        app.mount("/public", StaticFiles(directory="/public"), name="static")
    else:
        app.mount("/public", StaticFiles(directory="/debitcard/debitcard/public/static"), name="static")
    }

How can I know in python if the code is actually running on my laptop or the cloud run environment?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The answer is to simply set environment variables in all the environments the code will run.

On my laptop, I'll do this:

 export DEBUG=True
 export LAPTOP=True
 export CLOUDRUN=False
 export GITHUBACTIONS=False

and on Google Cloud Run, I'll set the environment vars aswell. aswell as on GitHub Actions....

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!