Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set google credentials from google credential.json file in production #25858

Open
kashifcodility opened this issue May 6, 2024 · 0 comments
Assignees

Comments

@kashifcodility
Copy link

kashifcodility commented May 6, 2024

Hi,

i'm using gem 'google-cloud-run-client' for creating services. below is my code

                ::Google::Cloud::Run::V2::Services::Client.configure do |config|
                   config.timeout = 50.0
                end

                client = Google::Cloud::Run::V2::Services::Client.new

               request = Google::Cloud::Run::V2::CreateServiceRequest.new(
               parent: "projects/bot-up-2021/locations/us-central1",
               service: {
                    template: {
                       containers: [{
                          image: "us-central1-docker.pkg.dev/dev-setup:latest",
                      env: [
                         {
                           name: "INTERVIEW_QUESTIONS",
                           value: application.questions
                         },
                        {
                           name: "INTERVIEWEE_PROFILE",
                           value: application.interviewee_profile
                        },
                        {
                            name: "INTERVIEW_CONTEXT",
                            value: application.interview_context
                        },
                        {
                           name: "AI_MODEL",
                           value: application&.gpt_model&.name
                        },
                        {
                           name: "OPENAI_ORGANIZATION_ID", 
                           value: "org-dsfh342hhj23423h4hj2h"
                        },
                        {
                          name: "OPENAI_API_KEY",
                          value: "sk-proj-xjfwerlwehhfsdjfkljdklfjlksjld"
                        }
                       ]
                     },]                
                      }
                     },
                       service_id: application.slug,
                       validate_only: false
                   )
      # Call the create_service method.
      result = client.create_service request
      result.wait_until_done!

      if result.response?
        result.response.name.split('/').last
        p result.response
      else            
        puts "No response received."
      end

    rescue Exception => e
       binding.pry    
    end

in local environment i am setting like export GOOGLE_APPLICATION_CREDENTIALS="/home/lap-053/rails/interviewManagementSystem/interviewbot-2023-7a0ec8bff648.json". but i can't do it in production.

Questions

  1. what will be solution for it to set "GOOGLE_APPLICATION_CREDENTIALS" in production mode when deploy it on google cloud run?
  2. i want also set "CreateServiceRequest" as public not private, so it should not authenticate. how i can set parameters for it?

Kindly help.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants