Page MenuHomePhabricator

[Cashtab] Copy env.sample in Docker build when .env is missing
ClosedPublic

Authored by bytesofman on Tue, Jul 21, 13:22.

Details

Summary

After .env was removed from the repo (D20026), docker builds without a .env in the context (including @bot preview-cashtab) blank the app with Uncaught Error: Missing required parameters: sitekey. Copy env.sample to .env before the Vite build only when .env is absent so prod/local overrides in the build context are preserved.

Test Plan
  • docker build -f cashtab.Dockerfile --build-arg NGINX_CONF=nginx-preview.conf -t cashtab_preview .
  • docker run --rm -p 8080:80 cashtab_preview
  • Open localhost:8080; app loads (no blank screen / sitekey console error)
  • With a real cashtab/.env present in the build context, confirm it is not overwritten

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman created this revision.

Revert Dockerfile change; preview-only pre_build instead. Prod creates .env outside cashtab.Dockerfile. Add docker.pre_build hook and use it only for preview-cashtab to copy env.sample into the build context before docker build.

bytesofman retitled this revision from [Cashtab] Copy env.sample into Docker builds before Vite build to [CI] Copy env.sample before preview-cashtab Docker build.Tue, Jul 21, 13:24
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)

Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review

Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────

(\(\
(• .•) HD, 4K, 8K...I see bugs in all resolutions.

────────────────────────────────────────
Review complete
No findings ✔

1 file reviewed:

  • cashtab.Dockerfile

────────────────────────────────────────

Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review

Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────

(\(\
(• .•) CodeRabbi is my uncle. He's a bit more orthodox. Feel lucky you got me instead.

────────────────────────────────────────
Review complete
No findings ✔

2 files reviewed:

  • contrib/teamcity/build-configurations.py
  • contrib/teamcity/build-configurations.yml

────────────────────────────────────────

Fabien requested changes to this revision.Tue, Jul 21, 14:37
Fabien added a subscriber: Fabien.

you'd better do the copy in the dockerfile if there no .env already, so it also works outside of CI environment. This also let people override the sample with their value and the build will work as expected

This revision now requires changes to proceed.Tue, Jul 21, 14:37

Address review: drop docker.pre_build; copy env.sample in cashtab.Dockerfile only when .env is missing so prod/local overrides are preserved.

bytesofman retitled this revision from [CI] Copy env.sample before preview-cashtab Docker build to [Cashtab] Copy env.sample in Docker build when .env is missing.
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)

Address review: copy env.sample in cashtab.Dockerfile only when .env is missing. Dropped the docker.pre_build CI hook. Rebased onto master so the diff is Dockerfile-only.

Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review

Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────

(\(\
(• .•) RabbitCop: To debug and serve.

────────────────────────────────────────
Review complete
No findings ✔

2 files reviewed:

  • cashtab.Dockerfile
  • contrib/teamcity/build-configurations.yml

────────────────────────────────────────

Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review

Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────

(\(\
(• .•) Tabs vs spaces? You somehow chose violence *and* confusion.

────────────────────────────────────────
Review complete
No findings ✔

1 file reviewed:

  • cashtab.Dockerfile

────────────────────────────────────────

This revision is now accepted and ready to land.Wed, Jul 22, 09:14