3.7 KiB
Setup Steps
The solution supports both local execution and deployment to Cloud Run environments.
Running Locally
-
Clone Repository: Clone the repository containing the solution's code to your local machine.
-
Install Dependencies: Navigate to the project directory and install dependencies from requirements.txt using pip.
-
Set Environment Variables: Create a
.envfile in the project directory and populate it with necessary environment variables:PROJECT_ID=<Your_Google_Cloud_Project_ID> LOCATION=<Desired_Location> REGION=<Desired_Google_Cloud_Project_Region> YOUR_EMAIL=<Your_Email_Address_Associated_With_Google_Cloud_Project> PROJECT_NUMBER=<Your_Google_Cloud_Project_Number> -
Run the Application: Execute the following command to run the application locally:
python -m streamlit run app/Home.py -
Access the Application: Once the application is running locally, access it through a web browser using the specified local host address and port.
Deployment Steps
Follow the below steps to deploy the solution to Cloud Run environment.
Google Cloud Storage Setup
-
Create Bucket: Manually create GCS bucket 'product_innovation_bucket' using either the Google Cloud Console or command-line tools (gsutil). The bucket is necessary for:
document_uploads: Stores market research, surveys, trend reports, etc.generated_products: Stores output images, descriptions, etc.image_edits: Stores intermediate/modified images during the regeneration process.
Using the Google Cloud Console (Web Interface):
- Navigate to the Google Cloud Storage section of your Google Cloud console.
- Click on the "Create Bucket" button.
- Provide the following details:
- Name: Enter 'product_innovation_bucket' as bucket name.
- Location: Choose a region closest to where your solution will operate for best performance.
- Storage Class: Select the class based on frequency of access and cost considerations.
- Advanced Settings: Adjust encryption, access control, etc., if necessary.
- Click "Create".
Using the 'gsutil' Command-Line Tool:
-
Ensure that you have the gcloud SDK installed and 'gsutil' configured.
-
Run the following command in your terminal, replacing
<region>with your desired bucket location:gcloud storage buckets create --location <region> gs://product_innovation_bucket
Environment Setup
- Ensure that the
configure_resources.shscript is in the directory containing the solution's code. - Create a
.envfile within the same directory and populate it with the same values as mentioned above. - Create a
.envfile in the 'cloud_functions' directory and populate it with necessary environment variables as mentioned above.
Execute the Script
-
Open a terminal and navigate to the directory containing the script and
env.txtfile. -
Run the script
configure-resources.shusing the command:sh configure-resources.sh -
The script will:
- Parse
.envto obtain project details. - Initialize gcloud and set project configuration.
- Set up a service account with necessary IAM roles.
- Deploy Cloud Functions (
imagen-call,gemini-call,text-embedding). - Capture URLs for deployed Cloud Functions.
- Deploy the main application to Cloud Run.
- Ensure that the service account has been created and manually grant the following roles to the created service account
retail-accelerating-prod-i-982@[PROJECT_ID].iam.gserviceaccount.com:- Service account user
- Cloud Run Admin
- Cloud Storage Admin
- Parse