Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda