# ----- Build Stage -----
# Using a specific Ruby version (e.g., 3.3) for stability
ARG RUBY_VERSION=3.4.8
FROM docker.io/library/ruby:3.4.8-slim as base

# Install production system dependencies
RUN --mount=type=cache,target=/var/cache/apt \
  --mount=type=cache,target=/var/lib/apt,sharing=locked \
  --mount=type=tmpfs,target=/var/log \
  rm -f /etc/apt/apt.conf.d/docker-clean; \
  apt-get update -qq \
  && apt-get install -yq --no-install-recommends \
    build-essential \
    less \
    git \
    cron \
    curl \
    dos2unix  \
    tdsodbc \
    freetds-dev \
    libvips \
    libpq-dev \
    libyaml-dev

ENV LANG=C.UTF-8 \
  BUNDLE_JOBS=4 \
  BUNDLE_RETRY=3

WORKDIR /usr/src/app

RUN gem install foreman

# COPY bin/development-entrypoint.sh /bin/development-entrypoint.sh
# RUN chown root:root bin/development-entrypoint.sh && chmod +x bin/development-entrypoint.sh

ENTRYPOINT ["./bin/development-entrypoint"]

# ENTRYPOINT ["./bin/cron-entrypoint"]


# Expose the application port
EXPOSE 3002

# Set the default command to run the Rails server
CMD ["./bin/dev"]
