-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
37 lines (28 loc) · 1.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
FROM ruby:2.7-slim
WORKDIR /app
RUN apt-get update && \
apt-get install --no-install-recommends -y \
build-essential \
libpq-dev \
nodejs \
libjemalloc2 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# configure jemalloc v5 with v3 behaviours (trade ram usage over performance)
# https://twitter.com/nateberkopec/status/1442894624935137288
# https://github.com/code-dot-org/code-dot-org/blob/5c8b24674d1c2f7e51e85dd32124e113dc423d84/cookbooks/cdo-jemalloc/attributes/default.rb#L10
ENV MALLOC_CONF="narenas:2,background_thread:true,thp:never,dirty_decay_ms:1000,muzzy_decay_ms:0"
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
ADD ./Gemfile /app/
ADD ./Gemfile.lock /app/
ENV PORT=80
ARG RAILS_ENV=production
ENV RAILS_ENV=$RAILS_ENV
RUN bundle config --global jobs `cat /proc/cpuinfo | grep processor | wc -l | xargs -I % expr % - 1` && \
if echo "development test" | grep -w "$RAILS_ENV"; then \
bundle install; \
else bundle install --without development test; fi
ADD ./ /app
RUN (cd /app && mkdir -p tmp/pids)
RUN (cd /app && SECRET_KEY_BASE=1 bundle exec rails assets:precompile)
EXPOSE 80
CMD ["/app/docker/start-puma.sh"]