ARG RUBY_VERSION=4
FROM ruby:${RUBY_VERSION}-slim
ENV BUNDLE_PATH /usr/local/bundle/gems
ENV LIB_PATH /var/grape
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential curl git pkg-config libyaml-dev libjemalloc2 && \
rm -rf /var/lib/apt/lists/*
RUN gem update --system && gem install bundler
ENV LD_PRELOAD libjemalloc.so.2
ENV MALLOC_CONF dirty_decay_ms:1000,narenas:2,background_thread:true
ENV RUBYOPT --enable-frozen-string-literal --yjit
WORKDIR $LIB_PATH
COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY . .
RUN bundle check || bundle install
CMD ["rake","spec"]
ENTRYPOINT ["docker-entrypoint.sh"]
FROM ruby:3.2-slim
ENV BUNDLE_PATH /usr/local/bundle/gems
ENV LIB_PATH /var/grape
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential curl git pkg-config libyaml-dev libjemalloc2 && \
rm -rf /var/lib/apt/lists/*
RUN gem update --system && gem install bundler
ENV LD_PRELOAD libjemalloc.so.2
ENV MALLOC_CONF dirty_decay_ms:1000,narenas:2,background_thread:true
ENV RUBYOPT --enable-frozen-string-literal --yjit
WORKDIR $LIB_PATH
COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY . .
RUN bundle check || bundle install
CMD ["rake","spec"]
ENTRYPOINT ["docker-entrypoint.sh"]
# Ignore Git and Bundler related stuff .git .bundle log/ tmp/ **/*.rbc .
Concerns: Consider adding a .dockerignore to reduce image context size and avoid copying unnecessary files., Ensure docker-entrypoint.sh properly uses exec to forward signals to the child process; otherwise signals may not propagate correctly. Smoke [PASS]: cd /var/grape && bundle check Smoke [PASS]: ruby -v Smoke [FAIL]: cd /var/grape && bundle exec ruby -e 'begin; require \"grape\"; puts \"grape loaded\"; rescue => e; puts e.class; exit 1; end Output: sh: 1: Syntax error: Unterminated quoted string
Concerns: LD_PRELOAD uses libjemalloc.so.2 without an absolute path which may fail to preload at runtime; consider using the full path (e.g., /usr/lib/x86_64-linux-gnu/libjemalloc.so.2)., Running tests via rake spec in smoke tests could be brittle if external resources are required; the provided commands mitigate by listing tasks instead of executing the full suite. Smoke [PASS]: ruby -v Smoke [PASS]: bundle check Smoke [PASS]: bundle exec rake -T