Dockerfile34 lines · 828 chars # Use a lightweight Ruby base image
FROM ruby:3.1-slim
ENV RACK_ENV=production
# Install system dependencies
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
build-essential curl ca-certificates libxml2-dev libxslt1-dev zlib1g-dev bash && \
rm -rf /var/lib/apt/lists/* && \
ln -sf /bin/bash /bin/sh
# Set workdir and copy source
WORKDIR /app
COPY . .
# Install Rack (no Gemfile present in this repo)
RUN gem update --system && gem install rack
# Create a non-root user and set permissions
RUN useradd -m app
RUN chown -R app:app /app
USER app
# Expose port 9292 for Rack server
EXPOSE 9292
# Healthcheck to verify container readiness
HEALTHCHECK CMD curl -fsS http://localhost:9292/health || exit 1
# Start Rack server
CMD ["rackup", "config.ru", "-o", "0.0.0.0", "-p", "9292"]