Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RVM install with jemalloc #279

Closed
prdanelli opened this issue Apr 4, 2020 · 7 comments
Closed

RVM install with jemalloc #279

prdanelli opened this issue Apr 4, 2020 · 7 comments

Comments

@prdanelli
Copy link

prdanelli commented Apr 4, 2020

Hello, I searched your previous issues but couldn't find anything related to this, but I apologise if its the wrong place.

I am dockerizing a large rails app and trying to use Passenger Docker as a base, however I cannot seem to find a way to RVM install ruby with the -C -with-jemalloc flag appended.

I tried adding RUN /usr/local/rvm/bin/rvm reinstall ruby-2.6.5 -C -with-jemalloc after the initial FROM phusion/passenger-ruby26, however this seems to error when compiling:

Step 4/23 : RUN /usr/local/rvm/bin/rvm reinstall ruby-2.6.5 -C -with-jemalloc
 ---> Running in a9907366cc38
ruby-2.6.5 - #removing rubies/ruby-2.6.5..
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system.....
Installing required packages: automake....
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.4M  100 13.4M    0     0  5323k      0  0:00:02  0:00:02 --:--:-- 5323k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting ruby-2.6.5 to /usr/local/rvm/src/ruby-2.6.5.....
ruby-2.6.5 - #configuring..........................
Error running './configure --prefix=/usr/local/rvm/rubies/ruby-2.6.5 -with-jemalloc --disable-install-doc --enable-shared',
please read /usr/local/rvm/log/1586007632_ruby-2.6.5/configure.log
There has been an error while running configure. Halting the installation.

Is there a flag that can be added or an environment variable that I am unaware of, or is this just something you do not support?

I'll add my full Dockerfile for reference below:

FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf-builder
FROM prwhitehead/vips-alpine:latest as vips-builder

FROM phusion/passenger-ruby26 AS base

RUN curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
	echo 'deb https://deb.nodesource.com/node_10.x xenial main' > /etc/apt/sources.list.d/nodesource.list && \
 	curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -  && \
 	echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
 	apt-add-repository -y "deb http://security.ubuntu.com/ubuntu bionic-security main" && \
 	apt-get update -qq && \
 	apt-get install -y -qq --no-install-recommends \
 		software-properties-common build-essential python pkg-config glib2.0-dev libexpat1-dev yarn tzdata imagemagick xvfb redis-tools ruby-dev && \
	rm -rf /var/lib/apt/lists/*

RUN rm -fv /etc/nginx/sites-enabled/default /etc/service/nginx/down
COPY docker/nginx/vhost.conf /etc/nginx/sites-enabled/default
COPY docker/nginx/env.conf /etc/nginx/main.d/env.conf
COPY docker/nginx/passenger.conf /etc/nginx/conf.d/passenger.conf
COPY docker/nginx/client_max_body_size.conf /etc/nginx/conf.d/client_max_body_size.conf

WORKDIR /home/app

# Bundler
COPY --chown=app:app Gemfile* /home/app/
ENV LANG=C.UTF-8 BUNDLE_JOBS=4 BUNDLE_RETRY=3
RUN gem install bundler
RUN bundle config --global github.https true
RUN bundle install

COPY --chown=app:app package* yarn* /home/app/
ENV PATH /home/app/node_modules/.bin:$PATH
RUN yarn install

COPY --from=wkhtmltopdf-builder --chown=app:app /bin/wkhtmltopdf /usr/local/bin/
COPY --from=vips-builder --chown=app:app /usr/bin/vips /usr/local/bin/
COPY --chown=app:app . /home/app

USER app

Thank you in advance,
Paul.

@Gasparila
Copy link

Hi @prwhitehead, if it helps, this is what we do for our rails monolith:

FROM phusion/passenger-customizable as base
.....
# replace the ruby install line to add jemalloc
RUN sed -i 's/rvm install $RVM_ID/rvm install $RVM_ID -C --with-jemalloc/' /pd_build/ruby-2.6.sh
RUN /pd_build/ruby-2.6.sh

@prdanelli
Copy link
Author

Hello @Gasparila, thank you for taking the time to reply.

Have you copied the pd_builder files to your local file system, as the code above gives me the following error when I build:

Status: Downloaded newer image for phusion/passenger-customizable:latest
 ---> 92515871b85b
Step 3/32 : RUN sed -i 's/rvm install $RVM_ID/rvm install $RVM_ID -C --with-jemalloc/' /pd_build/ruby-2.6.sh
 ---> Running in c287665f53a9
sed: can't read /pd_build/ruby-2.6.sh: No such file or directory
ERROR: Service 'web' failed to build: The command '/bin/sh -c sed -i 's/rvm install $RVM_ID/rvm install $RVM_ID -C --with-jemalloc/' /pd_build/ruby-2.6.sh' returned a non-zero code: 2

@Gasparila
Copy link

If you are on latest you'll need to specify full ruby name ruby-2.6.5.sh. List of available shell files: https://github.com/phusion/passenger-docker/tree/master/image (image gets copied into /pd_build in https://github.com/phusion/passenger-docker/blob/master/image/Dockerfile#L4)
so

FROM phusion/passenger-customizable as base
.....
# replace the ruby install line to add jemalloc
RUN sed -i 's/rvm install $RVM_ID/rvm install $RVM_ID -C --with-jemalloc/' /pd_build/ruby-2.6.5.sh
RUN /pd_build/ruby-2.6.5.sh

Should work

@prdanelli
Copy link
Author

@Gasparila Thank you so much for your help. I'll check it out and see if I can get it working :)

@rept
Copy link

rept commented Apr 11, 2020

@Gasparila I'm following this thread too. I tried out your config, it built fine.

However when I try to validate it's using Jemalloc like this:

ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"

It doesn't seem to be the case. (I've also installed libjemalloc-dev and also set LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1)

Any ideas? @prwhitehead did it work on your end?

@rept
Copy link

rept commented Apr 11, 2020

Hmmm ignore, apparently the check is now:

MALLOC_CONF=stats_print:true ruby -e "exit"

If you see stats ouput, it's working.

source: gaffneyc/heroku-buildpack-jemalloc#5 (comment)

@CamJN
Copy link
Member

CamJN commented Oct 4, 2021

I'm going to close this as it's not something we're going to actively support.

@CamJN CamJN closed this as completed Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants