Skip to content
Open

update #1240

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 14 additions & 62 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,23 @@
envVarGroups:
- name: spree-envs
envVars:
- key: DB_POOL
value: 10

databases:
- name: spree-db
databaseName: spree
user: spree
plan: basic-1gb
diskSizeGB: 10

services:
- type: web
name: spree-web
runtime: ruby
plan: standard
buildCommand: bin/render-build.sh
preDeployCommand: bin/rails db:migrate && bin/rails db:seed
startCommand: "bundle exec puma -C config/puma.rb"
name: spree-storefront
env: ruby
plan: free
buildCommand: |
bundle install &&
RAILS_ENV=production bundle exec rails assets:precompile &&
RAILS_ENV=production bundle exec rails db:migrate
startCommand: bundle exec rails server -b 0.0.0.0
Comment on lines +6 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing dynamic port binding and optimize build steps

  • The startCommand is missing -p $PORT, which Render injects at runtime. Without it, Rails defaults to port 3000 and won’t receive external traffic.
  • You can also speed up installs by excluding dev/test gems and parallelizing:
 buildCommand: |
-  bundle install &&
+  bundle install --without development test --jobs 4 &&
   RAILS_ENV=production bundle exec rails assets:precompile &&
   RAILS_ENV=production bundle exec rails db:migrate
 startCommand: bundle exec rails server -b 0.0.0.0

Apply:

-startCommand: bundle exec rails server -b 0.0.0.0
+startCommand: bundle exec rails server -b 0.0.0.0 -p $PORT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
buildCommand: |
bundle install &&
RAILS_ENV=production bundle exec rails assets:precompile &&
RAILS_ENV=production bundle exec rails db:migrate
startCommand: bundle exec rails server -b 0.0.0.0
buildCommand: |
bundle install --without development test --jobs 4 &&
RAILS_ENV=production bundle exec rails assets:precompile &&
RAILS_ENV=production bundle exec rails db:migrate
startCommand: bundle exec rails server -b 0.0.0.0 -p $PORT
🤖 Prompt for AI Agents
In render.yaml around lines 6 to 10, the startCommand lacks dynamic port binding
by missing the '-p $PORT' option, causing Rails to default to port 3000 and
block external traffic. Fix this by adding '-p $PORT' to the startCommand.
Additionally, optimize the buildCommand by excluding development and test gems
during bundle install using '--without development test' and enable parallel
installation with '--jobs 4 --retry 3' to speed up the process.

envVars:
- key: DATABASE_URL
fromDatabase:
name: spree-db
property: connectionString
- key: SECRET_KEY_BASE
sync: false
- key: WEB_CONCURRENCY
value: 2 # sensible default
- key: REDIS_URL
fromService:
type: keyvalue
name: keyvalue
property: connectionString
- type: worker
name: spree-worker
runtime: ruby
plan: standard
buildCommand: bin/render-build.sh
startCommand: bundle exec sidekiq
envVars:
generateValue: true
- key: RAILS_ENV
value: production
Comment on lines +13 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing Rails master key for encrypted credentials

You’re auto-generating SECRET_KEY_BASE, but if the app uses encrypted credentials (credentials.yml.enc), you must supply RAILS_MASTER_KEY in production. Otherwise tasks like migrations or asset compilation can fail.

Example:

- key: RAILS_MASTER_KEY
  fromSecret:
    name: spree-credentials
    property: masterKey
🤖 Prompt for AI Agents
In render.yaml around lines 13 to 15, the environment variables are missing the
RAILS_MASTER_KEY needed for encrypted credentials in production. Add a new
environment variable entry with key RAILS_MASTER_KEY that sources the master key
from the appropriate secret, for example using fromSecret with the secret name
spree-credentials and property masterKey, to ensure encrypted credentials can be
accessed during runtime.

- key: DATABASE_URL
fromDatabase:
name: spree-db
property: connectionString
- key: REDIS_URL
fromService:
type: keyvalue
name: keyvalue
property: connectionString
- key: SECRET_KEY_BASE
sync: false
- key: REDIS_CACHE_URL
fromService:
type: keyvalue
name: keyvalue-cache
property: connectionString
- fromGroup: spree-envs

- type: keyvalue
name: keyvalue
ipAllowList: []
plan: starter
maxmemoryPolicy: noeviction

- type: keyvalue
name: keyvalue-cache
ipAllowList: []
plan: starter
maxmemoryPolicy: allkeys-lru
databases:
- name: spree-db
plan: free