34 lines
700 B
Text
34 lines
700 B
Text
|
|
# Use official Ruby image
|
||
|
|
FROM ruby:3.2-slim
|
||
|
|
|
||
|
|
# Set working directory
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Install system dependencies
|
||
|
|
RUN apt-get update && apt-get install -y \
|
||
|
|
build-essential \
|
||
|
|
&& rm -rf /var/lib/apt/lists/*
|
||
|
|
|
||
|
|
# Copy Gemfile and Gemfile.lock
|
||
|
|
COPY Gemfile* ./
|
||
|
|
|
||
|
|
# Install Ruby gems
|
||
|
|
RUN bundle install --without development
|
||
|
|
|
||
|
|
# Copy application code
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Create non-root user
|
||
|
|
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
||
|
|
RUN chown -R appuser:appuser /app
|
||
|
|
USER appuser
|
||
|
|
|
||
|
|
# Expose port
|
||
|
|
EXPOSE 4567
|
||
|
|
|
||
|
|
# Health check
|
||
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||
|
|
CMD curl -f http://localhost:4567/health || exit 1
|
||
|
|
|
||
|
|
# Default command
|
||
|
|
CMD ["ruby", "app.rb"]
|