Skip to content

Fix Docker build SECRET_KEY_BASE validation error during asset precompilation#369

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-330
Draft

Fix Docker build SECRET_KEY_BASE validation error during asset precompilation#369
Copilot wants to merge 2 commits intomainfrom
copilot/fix-330

Conversation

Copy link
Contributor

Copilot AI commented Aug 20, 2025

The Docker build was failing during asset precompilation with the error:

ArgumentError: `secret_key_base` for production environment must be a type of String`

This occurred because the Rails application has validation that requires SECRET_KEY_BASE to be a properly formatted string in production environment. The existing approach used SECRET_KEY_BASE_DUMMY=1, which only provided a 1-character value that failed Rails 7.x validation requirements.

Changes Made

Dockerfile: Updated both asset precompilation commands to generate proper 128-character hexadecimal secret keys:

# Before
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile

# After  
RUN SECRET_KEY_BASE=$(ruby -e "require 'securerandom'; puts SecureRandom.hex(64)") ./bin/rails assets:precompile

docker/README.md: Added build notes explaining the fix and Rails requirements.

Security & Safety

  • Generated keys are only used during build-time asset precompilation
  • Keys are not persisted in the final Docker image
  • Fresh keys are generated for each build
  • Runtime SECRET_KEY_BASE is still provided via environment variables as before

This fix allows the Docker build process to complete successfully while maintaining security best practices.

Fixes #330.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@naveed-ahmad 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@zeet-co
Copy link

zeet-co bot commented Aug 20, 2025

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://quranic-universal-library-my2s-co-8104f6.tarteel-v3.tarteel.io before merging 😉

Co-authored-by: naveed-ahmad <701567+naveed-ahmad@users.noreply.github.com>
Copilot AI changed the title [WIP] Error building docker image Fix Docker build SECRET_KEY_BASE validation error during asset precompilation Aug 20, 2025
Copilot AI requested a review from naveed-ahmad August 20, 2025 13:20
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

Successfully merging this pull request may close these issues.

Error building docker image

2 participants