Move the production image to ruby:4.0.9-slim-bookworm (same distro, so native gems build against the same libraries) and the dev shell to nixpkgs' ruby_4_0, also 4.0.9, so the tests run on the Ruby that ships. Ruby 4's Bundler 4 dropped `bundle install --without`; set BUNDLE_WITHOUT instead, which Bundler 2 reads too. The lockfile stays BUNDLED WITH 2.7.2 (nixpkgs' bundler; Bundler 4 switches to it). Checked before merging: the image builds, keeps the test gems out, and boots Puma 8.0.2 on Ruby 4.0.9 through to opening the database. Rollback: revert this commit and redeploy (or re-tag the previous image). Assisted-by: Claude:opus-5-5
34 lines
964 B
Docker
34 lines
964 B
Docker
FROM ruby:4.0.9-slim-bookworm
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
libpq-dev \
|
|
imagemagick \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN groupadd -g 11000 asxpio \
|
|
&& useradd -d /app -u 21000 -g 11000 -m -s /bin/bash asxpio
|
|
|
|
WORKDIR /app
|
|
USER asxpio
|
|
|
|
ENV GEM_HOME=/app/bundle
|
|
ENV PATH="${GEM_HOME}/bin:${PATH}"
|
|
|
|
COPY --chown=asxpio Gemfile Gemfile.lock* ./
|
|
ENV BUNDLE_FROZEN=true
|
|
ENV BUNDLE_WITHOUT=development:test
|
|
RUN bundle install
|
|
|
|
COPY --chown=asxpio . .
|
|
|
|
ENV PUMA_PORT=3000
|
|
ENV PUMA_THREADS="4:16"
|
|
ENV RACK_ENV=production
|
|
EXPOSE 3000
|
|
|
|
# Slim image has no curl; ruby is right there.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD ruby -rnet/http -e 'port = ENV.fetch("PUMA_PORT", "3000"); exit(Net::HTTP.get_response(URI("http://127.0.0.1:#{port}/healthz")).code == "200" ? 0 : 1)'
|
|
|
|
CMD ["sh", "-c", "exec puma -b tcp://0.0.0.0:${PUMA_PORT} -t ${PUMA_THREADS} --preload"]
|