FROM ruby:3.4-slim

# 1. Install essential build tools for gems like 'pg' or 'sqlite3'
RUN apt-get update -qq && apt-get install -y \
    build-essential \
    libpq-dev \
    curl \
    git

WORKDIR /usr/src/game-data

# 2. Set environment variables for the Gem volume we discussed
ENV BUNDLE_PATH=/usr/local/bundle \
    BUNDLE_BIN=/usr/local/bundle/bin \
    PATH=/usr/local/bundle/bin:$PATH

# 3. Copy Gemfile first to leverage layer caching
COPY Gemfile Gemfile.lock ./
RUN bundle install

# 4. Copy the application code
COPY . ./

# 5. Make sure your entrypoint script is executable
RUN chmod +x entrypoints/dev.sh

ENTRYPOINT ["bash", "entrypoints/dev.sh"]
