(1) If you see a line like this in your deployment log, it is very likely your precompile process die because of insufficient memory.
bash: line 1: 29354 Killed $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
(2) Precompile is a memory hungry process especially when the amount of external JS modules increases. In order to fix this issue without buying more RAM, you can add SWAP space in Ubuntu.
(a) Creating a SWAP file. Make sure that you have enough HDD space before doing this.
sudo fallocate -l 1024m /mnt/swap1.swap
(b) Change the permission to 600.
sudo chmod 600 /mnt/swap1.swap
(c) Format the file to setup SWAP area.
sudo mkswap /mnt/swap1.swap
(d) Enable the SWAP area.
sudo swapon /mnt/swap1.swap
(e) Add an entry in /etc/fstab to mount this SWAP area after reboot.
# /etc/fstab /mnt/swap1.swap none swap sw 0 0
(3) Now, when you run precompile again, you will notice the SWAP area is being use and the process should complete without any issue.
$ sudo swapon -s Filename Type Size Used Priority /mnt/swap1.swap file 1048572 81424 -1