Skip to content

Containerize app, upgrade Rails to 8.1.3, and overhaul CI#76

Open
dsomel21 wants to merge 3 commits intomainfrom
containerize-and-ci
Open

Containerize app, upgrade Rails to 8.1.3, and overhaul CI#76
dsomel21 wants to merge 3 commits intomainfrom
containerize-and-ci

Conversation

@dsomel21
Copy link
Copy Markdown
Collaborator

What changed

Rails upgrade

  • Bump rails from 8.0.3 → 8.1.3 (latest stable) and regenerate Gemfile.lock

Docker / containerization

  • Rewrite Dockerfile with three named targets:
    • development – all gems installed to system path for live-reload with volume mounts
    • builder – production gems + bootsnap precompile (intermediate)
    • production – lean Alpine runtime, no build tooling; ships to Fly.io / GHCR
  • Add docker-compose.yml for one-command local dev (docker compose up)
    • web service with source-code volume mount and persistent SQLite volume
    • css service runs tailwindcss:watch alongside the web server
  • Add bin/docker-entrypoint that runs db:prepare before the server starts
  • Expand .dockerignore (exclude SQLite files, coverage, editors, etc.)
  • Add .env.example documenting all required/optional environment variables

GitHub Actions

  • Update ruby-ci.yml:
    • Upgrade actions/checkout v2 → v4
    • Enable bundler-cache: true on ruby/setup-ruby for faster CI
    • Split into two parallel jobs: lint (RuboCop) and test (RSpec)
  • Add docker.yml workflow:
    • Builds the production target on every PR/push (validates the image)
    • Pushes to ghcr.io/vidhiya-saagar/spg2 on merges to main and version tags
    • Uses GitHub Actions layer cache (type=gha) to speed up builds

README

  • Add Docker quick-start section (Option A) alongside the existing local setup
  • Document the three Dockerfile targets and compose commands
  • Add CI/CD workflow summary table

Description

New Changes

Closes # (issue)

How Has This Been Tested?

  • Added/Updated Specs
  • Manual Test

dsomel21 and others added 3 commits March 25, 2026 16:24
## What changed

### Rails upgrade
- Bump `rails` from 8.0.3 → 8.1.3 (latest stable) and regenerate Gemfile.lock

### Docker / containerization
- Rewrite `Dockerfile` with three named targets:
  - `development` – all gems installed to system path for live-reload with volume mounts
  - `builder`     – production gems + bootsnap precompile (intermediate)
  - `production`  – lean Alpine runtime, no build tooling; ships to Fly.io / GHCR
- Add `docker-compose.yml` for one-command local dev (`docker compose up`)
  - `web` service with source-code volume mount and persistent SQLite volume
  - `css` service runs `tailwindcss:watch` alongside the web server
- Add `bin/docker-entrypoint` that runs `db:prepare` before the server starts
- Expand `.dockerignore` (exclude SQLite files, coverage, editors, etc.)
- Add `.env.example` documenting all required/optional environment variables

### GitHub Actions
- Update `ruby-ci.yml`:
  - Upgrade `actions/checkout` v2 → v4
  - Enable `bundler-cache: true` on `ruby/setup-ruby` for faster CI
  - Split into two parallel jobs: `lint` (RuboCop) and `test` (RSpec)
- Add `docker.yml` workflow:
  - Builds the `production` target on every PR/push (validates the image)
  - Pushes to `ghcr.io/vidhiya-saagar/spg2` on merges to `main` and version tags
  - Uses GitHub Actions layer cache (`type=gha`) to speed up builds

### README
- Add Docker quick-start section (Option A) alongside the existing local setup
- Document the three Dockerfile targets and compose commands
- Add CI/CD workflow summary table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bin/rails, bin/rake, and bin/setup had shebangs pointing to a specific
developer's local RVM path (/Users/dilraj/.rvm/...) which doesn't exist
in Docker containers (or anyone else's machine). Replace with the
portable #!/usr/bin/env ruby form.

This fixes the "exec bin/rails: no such file or directory" error when
running `docker compose up`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two issues prevented `docker compose up` from working cleanly:

1. **CSS service crash** – tailwindcss-ruby couldn't find its aarch64
   binary because the dev stage used Alpine (musl libc) but platform gems
   are distributed as gnu binaries. Fix: use ruby:3.4.5-slim (Debian/glibc)
   for the development target so platform-specific gems work. Production
   target stays on Alpine for a lean image.

2. **Tailwind platform not in lockfile** – Added aarch64-linux,
   aarch64-linux-gnu, x86_64-linux-gnu to Gemfile.lock PLATFORMS so
   bundler selects the correct pre-compiled tailwindcss binary.

The stack now boots fully: web server on :1843, Tailwind watcher running,
/books and /books/1.json return JSON correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant