Skip to content

Commit

Permalink
Merge pull request #5996 from avalonmediasystem/jemalloc
Browse files Browse the repository at this point in the history
Upgrade to ruby 3.3 and enable jemalloc and YJIT
  • Loading branch information
cjcolvar authored Sep 3, 2024
2 parents d9dfe95 + 56de779 commit 43b075f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base stage for building gems
FROM ruby:3.2-bullseye as bundle
FROM ruby:3.3-bullseye as bundle
LABEL stage=build
LABEL project=avalon
RUN apt-get update && apt-get upgrade -y build-essential && apt-get autoremove \
Expand All @@ -10,6 +10,7 @@ RUN apt-get update && apt-get upgrade -y build-essential && apt-get autor
git \
ffmpeg \
libsqlite3-dev \
libjemalloc2 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

Expand All @@ -19,8 +20,11 @@ COPY Gemfile.lock ./Gemfile.lock
RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" \
&& bundle config build.nokogiri --use-system-libraries

ENV RUBY_THREAD_MACHINE_STACK_SIZE 8388608
ENV RUBY_THREAD_VM_STACK_SIZE 8388608
ENV RUBY_THREAD_MACHINE_STACK_SIZE 8388608 \
RUBY_THREAD_VM_STACK_SIZE 8388608 \
LD_PRELOAD="libjemalloc.so.2" \
MALLOC_CONF="dirty_decay_ms:1000,narenas:2,background_thread:true" \
RUBY_YJIT_ENABLE=1


# Build development gems
Expand All @@ -33,7 +37,7 @@ RUN bundle config set --local without 'production' \


# Download binaries in parallel
FROM ruby:3.2-bullseye as download
FROM ruby:3.3-bullseye as download
LABEL stage=build
LABEL project=avalon
RUN curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-amd64-v0.6.1.tar.gz | tar xvz -C /usr/bin/
Expand All @@ -46,7 +50,7 @@ RUN apt-get -y update && apt-get install -y ffmpeg


# Base stage for building final images
FROM ruby:3.2-slim-bullseye as base
FROM ruby:3.3-slim-bullseye as base
LABEL stage=build
LABEL project=avalon
RUN echo "deb http://ftp.us.debian.org/debian/ bullseye main contrib non-free" > /etc/apt/sources.list.d/bullseye.list \
Expand Down Expand Up @@ -77,13 +81,18 @@ RUN apt-get update && \
zip \
dumb-init \
libsqlite3-dev \
libjemalloc2 \
&& apt-get -y install mediainfo \
&& ln -s /usr/bin/lsof /usr/sbin/

RUN useradd -m -U app \
&& su -s /bin/bash -c "mkdir -p /home/app/avalon" app
WORKDIR /home/app/avalon

ENV LD_PRELOAD="libjemalloc.so.2" \
MALLOC_CONF="dirty_decay_ms:1000,narenas:2,background_thread:true" \
RUBY_YJIT_ENABLE=1


# Build devevelopment image
FROM base as dev
Expand Down

0 comments on commit 43b075f

Please sign in to comment.