Skip to content

Commit

Permalink
try optimising deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
madhums committed Mar 6, 2024
1 parent a11f134 commit 73eef2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ USER rails:rails
ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true"

# Enable jemalloc for better memory performance
# https://fly.io/docs/rails/cookbooks/deploy/#jemalloc
# And enable YJIT for better Ruby performance
# https://fly.io/docs/rails/cookbooks/deploy/#yjit
#
RUN apt-get install libjemalloc2
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 \
MALLOC_CONF=dirty_decay_ms:1000,narenas:2,background_thread:true \
RUBY_YJIT_ENABLE=1

# Entrypoint sets up the container.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

Expand Down
9 changes: 9 additions & 0 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@

# Add any container initialization steps here

# Enable swap https://fly.io/docs/rails/cookbooks/deploy/#enabling-swap
#
fallocate -l 128M /swapfile
chmod 0600 /swapfile
mkswap /swapfile
echo 10 > /proc/sys/vm/swappiness
swapon /swapfile
echo 1 > /proc/sys/vm/overcommit_memory

exec "${@}"

0 comments on commit 73eef2d

Please sign in to comment.