FROM ruby:3.4.9-alpine3.23
# Install build dependencies for native gems
RUN apk add --no-cache build-base ruby-dev libffi-dev
# Set work directory
WORKDIR /app
# Copy project files
COPY . .
# If Gemfile is not present in the repo, create a minimal Gemfile for predictable Bundler behavior
RUN set -e; if [ ! -f Gemfile ]; then printf "source 'https://rubygems.org'\n\ngem 'rack'\n" > Gemfile; fi
# Ensure Bundler is available and install dependencies
RUN gem install bundler
RUN bundle config set path 'vendor/bundle'
RUN bundle install
# Expose Rack port
EXPOSE 9292
# Run the Rack app
CMD ["bundle", "exec", "rackup", "-o", "0.0.0.0", "-p", "9292"]