Skip to content

Fully containerized development environment#571

Open
umxr wants to merge 9 commits intoTarteelAI:mainfrom
umxr:feat/containerized-dev-environment
Open

Fully containerized development environment#571
umxr wants to merge 9 commits intoTarteelAI:mainfrom
umxr:feat/containerized-dev-environment

Conversation

@umxr
Copy link
Copy Markdown
Contributor

@umxr umxr commented Apr 2, 2026

Summary

Closes #567

  • Adds a dev Dockerfile, entrypoint script, and 4 new Docker Compose services (web, js, tailwind, sidekiq) so the entire stack runs with docker compose up — no local Ruby, Node, or system deps needed
  • Adds a db:load_quran_dump rake task that auto-downloads and loads the quran_dev mini dump, hooked into rails db:setup for single-command DB setup
  • Adds a "Full Docker Setup" section to the README with step-by-step instructions and commands reference
  • Removes yarn.lock and standardizes on npm across Procfile.dev and package.json

New files

  • docker/dev/Dockerfile — Ruby 3.3.3-slim + system deps + Node.js 20
  • docker/dev/entrypoint.sh — Idempotent dep install with checksum caching, flock serialization, platform detection
  • lib/tasks/docker_setup.rakedb:load_quran_dump task + db:setup hook
  • .dockerignore — Excludes .git, tmp, node_modules from build context

Modified files

  • docker-compose.yml — Added x-app anchor, web/js/tailwind/sidekiq services, named volumes
  • README.md — Added "Full Docker Setup" section
  • Procfile.dev — Switched from yarn to npm
  • package.json — Switched size script from yarn to npm

Test plan

  • docker compose build completes successfully
  • docker compose up starts all 6 services (db, redis, web, js, tailwind, sidekiq)
  • docker compose exec web rails db:setup creates DBs, downloads/loads dump, migrates, seeds
  • Editing a Ruby file triggers automatic reload in the web container
  • Editing a JS file triggers esbuild rebuild via the js container
  • Editing a Tailwind class triggers CSS rebuild via the tailwind container
  • docker compose exec web rails console works
  • Existing infrastructure-only workflow (DB_HOST=localhost with local Ruby) still works unchanged
  • bin/dev still works for local development (Procfile.dev updated to npm)

umxr added 9 commits April 2, 2026 18:05
- Pin bundler to 2.5.15 in Dockerfile to match Gemfile.lock
- Add bundle lock --add-platform for Linux container compatibility
  (tailwindcss-rails needs platform-specific binaries)
- Add flock-based serialization in entrypoint to prevent concurrent
  npm/bundle installs across containers sharing named volumes
- Add .dockerignore to exclude .git, tmp, node_modules from build context
- Expose port 3005 on js service for esbuild live-reload EventSource
- Add mkdir -p for volume dirs in entrypoint for robustness
- Show psql stderr during dump loading instead of suppressing all output
- Delete yarn.lock (project uses package-lock.json)
- Update Procfile.dev to use npm run build
- Update package.json size script to use npm run build
@piraka9011 piraka9011 requested a review from naveed-ahmad April 6, 2026 15:12
Copy link
Copy Markdown
Contributor

@naveed-ahmad naveed-ahmad left a comment

Choose a reason for hiding this comment

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

I don't understand why we need to replace yarn with npm, and see other comments.

namespace :db do
desc 'Download and load the quran_dev mini dump if the database is empty'
task load_quran_dump: :environment do
dump_url = 'https://static-cdn.tarteel.ai/qul/mini-dumps/mini_quran_dev.sql.zip'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dump can be cached on CDN, lets add a cache bust query string. Value can be random, or current time.

dump_url = "URL?v=#{Time.now.to_i}"

rescue PG::Error => e
puts "[db:load_quran_dump] Could not connect to #{db_name}: #{e.message}"
puts '[db:load_quran_dump] Skipping dump load. See README for manual instructions.'
next
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you mean return ?


if result > 0
puts "[db:load_quran_dump] #{db_name} already has #{result} chapters. Skipping."
next
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dito: early return if db already has data.

zip_path = File.join(tmpdir, 'mini_quran_dev.sql.zip')

puts "[db:load_quran_dump] Downloading dump from #{dump_url}..."
system('wget', '-q', '--show-progress', '-O', zip_path, dump_url) || begin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a rake task, you can use our build in download utility.

Utils::Downloader.download(dump_url, zip_path)

puts "[db:load_quran_dump] Downloading dump from #{dump_url}..."
system('wget', '-q', '--show-progress', '-O', zip_path, dump_url) || begin
puts '[db:load_quran_dump] Download failed. See README for manual instructions.'
next
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

retrun

puts '[db:load_quran_dump] Extracting...'
system('unzip', '-o', '-d', tmpdir, zip_path) || begin
puts '[db:load_quran_dump] Extraction failed.'
next
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return

@@ -0,0 +1,75 @@
# frozen_string_literal: true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets rename the rake file name to qul_setup we can run this outside of docker as well.

end
end
end
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe move this downloading dump and populating db into a method and use it to prepare both quran_community_tarteel and quran_dev db.

Comment thread docker-compose.yml

tailwind:
<<: *app
command: bin/rails tailwindcss:watch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this rebuild the css bundle too?

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.

Fully containerized development environment

2 participants