From f8f800ab59d1f050bee49840e11d9523b649bf26 Mon Sep 17 00:00:00 2001 From: David del Real Sifuentes Date: Mon, 30 Nov 2026 22:54:13 +0000 Subject: [PATCH] plaveholder: WIP --- optional-kubernetes-engine/Dockerfile | 3 +-- optional-kubernetes-engine/README.md | 2 +- optional-kubernetes-engine/config.py | 34 ++++++++++++--------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/optional-kubernetes-engine/Dockerfile b/optional-kubernetes-engine/Dockerfile index 69f9d260..4c2bc41b 100644 --- a/optional-kubernetes-engine/Dockerfile +++ b/optional-kubernetes-engine/Dockerfile @@ -5,8 +5,7 @@ FROM gcr.io/google-appengine/python # Create a virtualenv for the application dependencies. -# If you want to use Python 2, add the -p python2.7 flag. -RUN virtualenv -p python3.4 /env +RUN virtualenv -p python3.14 /env # Set virtualenv environment variables. This is equivalent to running # source /env/bin/activate. This ensures the application is executed within diff --git a/optional-kubernetes-engine/README.md b/optional-kubernetes-engine/README.md index 9acb98b4..3a711dce 100644 --- a/optional-kubernetes-engine/README.md +++ b/optional-kubernetes-engine/README.md @@ -45,7 +45,7 @@ Alternatively, you can use make: ## Update config.py -Modify config.py and enter your Cloud Project ID into the `PROJECT_ID` and `CLOUD_STORAGE_BUCKET` field. The remaining configuration values are only needed if you wish to use a different database or if you wish to enable log-in via oauth2, which requires a domain name. +Take a look at config.py and set your Cloud Project ID `PROJECT_ID` and `CLOUD_STORAGE_BUCKET` environment variables using `export GOOGLE_CLOUD_PROJECT='your-project-id'`. The remaining configuration values are only needed if you wish to use a different database or if you wish to enable log-in via oauth2, which requires a domain name. ## Build the bookshelf container diff --git a/optional-kubernetes-engine/config.py b/optional-kubernetes-engine/config.py index 7da9b4cc..1351b8b4 100644 --- a/optional-kubernetes-engine/config.py +++ b/optional-kubernetes-engine/config.py @@ -21,29 +21,29 @@ import os # The secret key is used by Flask to encrypt session cookies. -SECRET_KEY = 'secret' +SECRET_KEY = os.getenv('SECRET_KEY') # There are three different ways to store the data in the application. # You can choose 'datastore', 'cloudsql', or 'mongodb'. Be sure to # configure the respective settings for the one you choose below. # You do not have to configure the other data backends. If unsure, choose # 'datastore' as it does not require any additional configuration. -DATA_BACKEND = 'datastore' +DATA_BACKEND = os.getenv('DATA_BACKEND','datastore') # Google Cloud Project ID. This can be found on the 'Overview' page at # https://console.developers.google.com -PROJECT_ID = 'your-project-id' +PROJECT_ID = os.getenv('GOOGLE_CLOUD_PROJECT') # CloudSQL & SQLAlchemy configuration # Replace the following values the respective values of your Cloud SQL # instance. -CLOUDSQL_USER = 'root' -CLOUDSQL_PASSWORD = 'your-cloudsql-password' -CLOUDSQL_DATABASE = 'bookshelf' +CLOUDSQL_USER = os.getenv('CLOUDSQL_USER') +CLOUDSQL_PASSWORD = os.getenv('CLOUDSQL_PASSWORD') +CLOUDSQL_DATABASE = os.getenv('CLOUDSQL_DATABASE') # Set this value to the Cloud SQL connection name, e.g. # "project:region:cloudsql-instance". # You must also update the value in app.yaml. -CLOUDSQL_CONNECTION_NAME = 'your-cloudsql-connection-name' +CLOUDSQL_CONNECTION_NAME = os.getenv('CLOUDSQL_CONNECTION_NAME') # The CloudSQL proxy is used locally to connect to the cloudsql instance. # To start the proxy, use: @@ -52,17 +52,13 @@ # # Alternatively, you could use a local MySQL instance for testing. LOCAL_SQLALCHEMY_DATABASE_URI = ( - 'mysql+pymysql://{user}:{password}@localhost/{database}').format( - user=CLOUDSQL_USER, password=CLOUDSQL_PASSWORD, - database=CLOUDSQL_DATABASE) + f'mysql+pymysql://{CLOUDSQL_USER}:{CLOUDSQL_PASSWORD}@localhost/{CLOUDSQL_DATABASE}') # When running on App Engine a unix socket is used to connect to the cloudsql # instance. LIVE_SQLALCHEMY_DATABASE_URI = ( - 'mysql+pymysql://{user}:{password}@localhost/{database}' - '?unix_socket=/cloudsql/{connection_name}').format( - user=CLOUDSQL_USER, password=CLOUDSQL_PASSWORD, - database=CLOUDSQL_DATABASE, connection_name=CLOUDSQL_CONNECTION_NAME) + f'mysql+pymysql://{CLOUDSQL_USER}:{CLOUDSQL_PASSWORD}@localhost/{CLOUDSQL_DATABASE}' + f'?unix_socket=/cloudsql/{CLOUDSQL_CONNECTION_NAME}') if os.environ.get('GAE_INSTANCE'): SQLALCHEMY_DATABASE_URI = LIVE_SQLALCHEMY_DATABASE_URI @@ -72,7 +68,8 @@ # Mongo configuration # If using mongolab, the connection URI is available from the mongolab control # panel. If self-hosting on compute engine, replace the values below. -MONGO_URI = 'mongodb://user:password@host:27017/database' +# format: mongodb://user:password@host:27017/database +MONGO_URI = os.getenv('MONGO_URI') # Google Cloud Storage and upload settings. # Typically, you'll name your bucket the same as your project. To create a @@ -87,7 +84,7 @@ # # You can adjust the max content length and allow extensions settings to allow # larger or more varied file types if desired. -CLOUD_STORAGE_BUCKET = 'your-bucket-name' +CLOUD_STORAGE_BUCKET = os.getenv('CLOUD_STORAGE_BUCKET') MAX_CONTENT_LENGTH = 8 * 1024 * 1024 ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif']) @@ -102,6 +99,5 @@ # # If you receive a invalid redirect URI error review you settings to ensure # that the current URI is allowed. -GOOGLE_OAUTH2_CLIENT_ID = \ - 'your-client-id' -GOOGLE_OAUTH2_CLIENT_SECRET = 'your-client-secret' +GOOGLE_OAUTH2_CLIENT_ID = os.getenv('GOOGLE_OAUTH2_CLIENT_ID') +GOOGLE_OAUTH2_CLIENT_SECRET = os.getenv('GOOGLE_OAUTH2_CLIENT_SECRET')