resume-resume-github-com
SUCCESS
24m 09s
History Source
SummaryIterations2Transcript32Dockerfile
Dockerfile39 lines · 1019 chars
FROM ruby:3.1-slim

# Install system dependencies required to build native extensions and run the app
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
  build-essential \
  libssl-dev \
  git \
  ca-certificates \
  tzdata \
  && rm -rf /var/lib/apt/lists/*

# Ensure Bundler is available
RUN gem install bundler

# Create a non-root user to run the application
RUN useradd -m appuser

WORKDIR /app

# Copy the complete application code
COPY . .

# Install dependencies if a Gemfile is present; otherwise install rack for a pure Rack app
RUN if [ -f Gemfile ]; then bundle install --without development test; else gem install rack; fi

# Ensure the app directory is owned by the non-root user
RUN chown -R appuser:appuser /app

# Copy startup script into image (to be executed as root, then switched to non-root user)
COPY start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh

USER appuser

EXPOSE 9292

# Start the server using the startup script
CMD ["/usr/local/bin/start.sh"]