Fully containerized development environment#571
Conversation
- 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
naveed-ahmad
left a comment
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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 |
|
|
||
| if result > 0 | ||
| puts "[db:load_quran_dump] #{db_name} already has #{result} chapters. Skipping." | ||
| next |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
| puts '[db:load_quran_dump] Extracting...' | ||
| system('unzip', '-o', '-d', tmpdir, zip_path) || begin | ||
| puts '[db:load_quran_dump] Extraction failed.' | ||
| next |
| @@ -0,0 +1,75 @@ | |||
| # frozen_string_literal: true | |||
There was a problem hiding this comment.
Lets rename the rake file name to qul_setup we can run this outside of docker as well.
| end | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Maybe move this downloading dump and populating db into a method and use it to prepare both quran_community_tarteel and quran_dev db.
|
|
||
| tailwind: | ||
| <<: *app | ||
| command: bin/rails tailwindcss:watch |
There was a problem hiding this comment.
does this rebuild the css bundle too?
Summary
Closes #567
docker compose up— no local Ruby, Node, or system deps neededdb:load_quran_dumprake task that auto-downloads and loads the quran_dev mini dump, hooked intorails db:setupfor single-command DB setupNew files
docker/dev/Dockerfile— Ruby 3.3.3-slim + system deps + Node.js 20docker/dev/entrypoint.sh— Idempotent dep install with checksum caching, flock serialization, platform detectionlib/tasks/docker_setup.rake—db:load_quran_dumptask +db:setuphook.dockerignore— Excludes .git, tmp, node_modules from build contextModified files
docker-compose.yml— Added x-app anchor, web/js/tailwind/sidekiq services, named volumesREADME.md— Added "Full Docker Setup" sectionProcfile.dev— Switched from yarn to npmpackage.json— Switched size script from yarn to npmTest plan
docker compose buildcompletes successfullydocker compose upstarts all 6 services (db, redis, web, js, tailwind, sidekiq)docker compose exec web rails db:setupcreates DBs, downloads/loads dump, migrates, seedsdocker compose exec web rails consoleworksDB_HOST=localhostwith local Ruby) still works unchangedbin/devstill works for local development (Procfile.dev updated to npm)