FROM ruby:3.4-slim-trixie

LABEL parent-images=ruby34

# Run updates and install additional packages
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y install build-essential curl make gcc \
  && gem update erb json net-imap \
  && apt remove -y build-essential make gcc \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/*

RUN rm -rf /usr/local/lib/ruby/gems/3.4.0/gems/json-2.9.1 \
  /usr/local/lib/ruby/gems/3.4.0/specifications/default/json-2.9.1.gemspec \
  /usr/local/lib/ruby/gems/3.4.0/gems/erb-4.0.4 \
  /usr/local/lib/ruby/gems/3.4.0/specifications/default/erb-4.0.4.gemspec \
  /usr/local/lib/ruby/gems/3.4.0/default/erb-4.0.4.gemspec \
  /usr/local/lib/ruby/gems/3.4.0/gems/net-imap-0.5.8 \
  /usr/local/lib/ruby/gems/3.4.0/specifications/default/net-imap-0.5.8.gemspec \
  /usr/local/lib/ruby/gems/3.4.0/specifications/net-imap-0.5.8.gemspec

RUN useradd -m -u 1010 --password '!' worker

# Run container as the worker user
USER worker
