Repository navigation
Upgrade supported runtimes and strengthen security and image checks #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
35ef908
Upgrade supported runtimes and harden dependency and image checks
philipithomas 10df3cc
Use Ruby 3.4-compatible ffi binaries on Linux
philipithomas a881b4e
Avoid duplicate CI runs for pull request branch pushes
philipithomas aacbe58
Install the approved browser and preserve solo homepage rendering
philipithomas e621aaa
Exercise production container startup and address runtime review
philipithomas 378cfb1
Install archive extraction support for Puppeteer in Docker
philipithomas 6f0b2d1
Serve patched bundled Trix and test editor paste sanitization
philipithomas c2e4a74
Merge main into runtime upgrade preserving Rails 8 protections
philipithomas a16d091
Integrate main cache fix and production request smoke coverage
philipithomas 7b53e9c
Sync runtime upgrade with coverage and retired Ghost integration
philipithomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Pay remains on v5 until its billing/data migration has separate validation. | ||
| # Every exception has an application regression test; do not expand this list | ||
| # to silence a new advisory. | ||
| ignore: | ||
| # Upstream's back-parameter XSS fix is backported in config/initializers/pay.rb. | ||
| # test/controllers/pay_payment_redirect_test.rb exercises the mounted payment | ||
| # route with script URLs, external URLs, invalid URLs, and a valid local path. | ||
| # https://github.com/pay-rails/pay/security/advisories/GHSA-cqf3-vpx7-rxhw | ||
| - CVE-2023-30614 | ||
| # Pay 5 has no PaddleBillingController or /webhooks/paddle_billing route. | ||
| # Paddle Billing was introduced in Pay 7. Only Stripe is enabled, and the | ||
| # same integration test verifies Paddle/Braintree endpoints are not routed. | ||
| # https://github.com/pay-rails/pay/blob/main/UPGRADE.md#pay-60-to-pay-70 | ||
| - GHSA-mjgf-xj26-9qf9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| .git | ||
| .github | ||
| .agents | ||
| .codex | ||
| .bundle | ||
| .env* | ||
| config/master.key | ||
| config/credentials/*.key | ||
| node_modules | ||
| .cache | ||
| log/* | ||
| !log/.keep | ||
| tmp/* | ||
| !tmp/.keep | ||
| storage/* | ||
| !storage/.keep | ||
| public/assets | ||
| app/assets/builds/* | ||
| !app/assets/builds/.keep | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 24.20.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.2.2 | ||
| 3.4.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| ruby 3.2.2 | ||
| ruby 3.4.10 | ||
| nodejs 24.20.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,118 +1,66 @@ | ||
| # syntax = docker/dockerfile:1 | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile | ||
| ARG RUBY_VERSION=3.2.2 | ||
| # Keep these versions aligned with .ruby-version and .node-version. | ||
| ARG RUBY_VERSION=3.4.10 | ||
| ARG NODE_VERSION=24.20.0 | ||
| FROM --platform=linux/amd64 node:${NODE_VERSION}-bookworm-slim AS node | ||
| FROM --platform=linux/amd64 ruby:${RUBY_VERSION}-slim-bookworm AS base | ||
|
|
||
| # Bookworm provides libvips >= 8.13, required by the Active Storage security patch. | ||
| FROM --platform=linux/amd64 ruby:$RUBY_VERSION-slim-bookworm AS base | ||
|
|
||
| # Rails app lives here | ||
| WORKDIR /rails | ||
|
|
||
| # Set production environment | ||
| ENV RAILS_ENV="production" \ | ||
| BUNDLE_WITHOUT="development:test" \ | ||
| BUNDLE_DEPLOYMENT="1" \ | ||
| RAILS_SERVE_STATIC_FILES="true" \ | ||
| DEBIAN_FRONTEND="noninteractive" \ | ||
| GROVER_NO_SANDBOX="true" | ||
|
|
||
|
|
||
| # Update gems and bundler | ||
| # Pin RubyGems to 3.5.x because tailwindcss-rails 2.0.25 uses Gem::Platform.match, | ||
| # which was removed in RubyGems 3.6+ | ||
| RUN gem update --system 3.5.22 --no-document && \ | ||
| gem install -N bundler | ||
|
|
||
| BUNDLE_WITHOUT="development:test:preview" \ | ||
| BUNDLE_DEPLOYMENT="1" \ | ||
| RAILS_SERVE_STATIC_FILES="true" \ | ||
| RAILS_LOG_TO_STDOUT="1" \ | ||
| GROVER_NO_SANDBOX="true" \ | ||
| PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD="true" \ | ||
| PUPPETEER_CACHE_DIR="/rails/.cache/puppeteer" | ||
|
|
||
| # Node's official binary avoids compiling Node during every image build. | ||
| COPY --from=node /usr/local/bin/node /usr/local/bin/node | ||
| COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules | ||
| RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ | ||
| ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx | ||
|
|
||
| # libvips >= 8.13 is required by the Active Storage security patch. | ||
| # Chromium is downloaded by the locked Puppeteer package; only its libraries | ||
| # are installed here, so no separate Chrome repository or browser is needed. | ||
| RUN apt-get update -qq && \ | ||
| apt-get install --no-install-recommends -y \ | ||
| ca-certificates curl imagemagick libvips postgresql-client \ | ||
| fonts-liberation fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg \ | ||
| fonts-kacst fonts-freefont-ttf libasound2 libatk-bridge2.0-0 libatk1.0-0 \ | ||
| libcups2 libdbus-1-3 libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 \ | ||
| libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 libxkbcommon0 \ | ||
| libxrandr2 libxshmfence1 libxss1 xdg-utils && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Throw-away build stage to reduce size of final image | ||
| FROM base AS build | ||
|
|
||
| # Install packages needed to build gems and node modules | ||
| RUN apt-get update -qq && \ | ||
| apt-get install --no-install-recommends -y build-essential curl libpq-dev libvips node-gyp pkg-config python-is-python3 dbus dbus-x11 && \ | ||
| service dbus start | ||
|
|
||
| # Install JavaScript dependencies | ||
| ARG NODE_VERSION=18.12.1 | ||
| ENV PATH=/usr/local/node/bin:$PATH | ||
| RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \ | ||
| /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \ | ||
| rm -rf /tmp/node-build-master | ||
| apt-get install --no-install-recommends -y build-essential libpq-dev pkg-config unzip && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install application gems | ||
| COPY --link Gemfile Gemfile.lock ./ | ||
| RUN bundle install && \ | ||
| rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git | ||
| rm -rf /usr/local/bundle/cache /usr/local/bundle/ruby/*/cache | ||
|
|
||
| # Install node modules | ||
| COPY --link package.json ./ | ||
| RUN npm install | ||
| COPY --link package.json package-lock.json ./ | ||
| RUN npm ci --omit=dev && \ | ||
| npx puppeteer browsers install chrome && \ | ||
| npm cache clean --force | ||
|
|
||
| # Copy application code | ||
| COPY --link . . | ||
|
|
||
| # Precompiling assets using build environment (production-like but without AWS dependencies) | ||
| RUN SECRET_KEY_BASE=DUMMY RAILS_ENV=build ./bin/rails assets:clobber | ||
| RUN SECRET_KEY_BASE=DUMMY RAILS_ENV=build ./bin/rails assets:precompile | ||
|
|
||
| # Final stage for app image | ||
| FROM base | ||
|
|
||
| # Install packages needed for deployment | ||
| RUN apt-get update -qq && \ | ||
| apt-get install --no-install-recommends -y curl imagemagick libvips postgresql-client && \ | ||
| rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
|
||
| # Puppeteer deps | ||
| RUN apt-get update \ | ||
| && apt-get install -y wget gnupg \ | ||
| && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
| && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
| && apt-get update \ | ||
| && apt-get install -y fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon-x11-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libnss3 libgtk-3-0 xvfb x11-apps x11-xkb-utils libx11-6 libx11-xcb1 \ | ||
| libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libatk1.0-0 libc6 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libnspr4 libpangocairo-1.0-0 libstdc++6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \ | ||
| --no-install-recommends | ||
|
|
||
| # Copy built artifacts: gems, application | ||
| COPY --from=build /usr/local/bundle /usr/local/bundle | ||
| COPY --from=build /rails /rails | ||
|
|
||
| # Copy Node.js and node_modules from build stage | ||
| COPY --from=build /usr/local/node /usr/local/node | ||
| COPY --from=build /rails/node_modules /rails/node_modules | ||
| ENV PATH=/usr/local/node/bin:$PATH | ||
|
|
||
|
|
||
| # Run and own only the runtime files as a non-root user for security | ||
| RUN useradd rails --create-home --shell /bin/bash && \ | ||
| chown -R rails:rails /rails && \ | ||
| chown -R rails:rails db log storage tmp /rails/node_modules | ||
| mkdir -p /rails/tmp/pids && \ | ||
| chown -R rails:rails /rails | ||
| USER rails:rails | ||
|
|
||
| # Deployment options | ||
| ENV RAILS_LOG_TO_STDOUT="1" \ | ||
| RAILS_SERVE_STATIC_FILES="true" | ||
|
|
||
| # Set up dbus | ||
| RUN mkdir -p /home/rails/.dbus && chown -R rails:rails /home/rails/.dbus | ||
| ENV DBUS_SESSION_BUS_ADDRESS=/home/rails/.dbus/system_bus_socket | ||
|
|
||
| # Set up Puppeteer environment | ||
| ENV PUPPETEER_CACHE_DIR=/home/rails/.cache/puppeteer \ | ||
| PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false | ||
|
|
||
| # Create Puppeteer cache directory with correct permissions | ||
| RUN mkdir -p $PUPPETEER_CACHE_DIR && \ | ||
| chown -R rails:rails $PUPPETEER_CACHE_DIR | ||
|
|
||
| # Install Puppeteer and Chrome | ||
| RUN cd /rails && \ | ||
| npm install puppeteer && \ | ||
| npx puppeteer browsers install chrome | ||
|
|
||
| # Entrypoint sets up the container. | ||
| ENTRYPOINT ["/rails/bin/docker-entrypoint"] | ||
|
|
||
| # Start the server by default, this can be overwritten at runtime | ||
| EXPOSE 3000 | ||
| CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.