Warning
Disclaimer: Building this application on a server, especially one with limited resources, is strongly discouraged as it can lead to instability and performance issues. For a more reliable and efficient deployment, we highly recommend pulling the pre-built Docker image from Docker Hub.
Official Docker Image: https://hub.docker.com/r/baderidris/nuxt-portfolio
If you must build on a server with limited resources (e.g., 1GB RAM, 1 vCPU, 25GB SSD), these instructions will guide you through the process.
- A server with
sudoprivileges.
A swap file can provide the additional memory needed for the build process.
-
Allocate a 4GB swap file:
# Use fallocate to create the swap file sudo fallocate -l 4G /swapfile # If fallocate is not available or fails, use dd instead # sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
-
Set the correct permissions:
sudo chmod 600 /swapfile
-
Set up the swap area:
sudo mkswap /swapfile
-
Activate the swap file:
sudo swapon /swapfile
Confirm that the swap space is active and recognized by the system.
free -hThe output should display a "Swap" line with a total size of approximately 4.0G.
To ensure the swap file is automatically mounted after a system reboot, add it to the /etc/fstab file.
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabSwappiness is a kernel parameter that controls how aggressively the system uses swap space. The value ranges from 0 to 100.
10: Recommended for servers. The kernel will favor keeping data in RAM.60: Default value.
To set swappiness to 10:
# Set the new value
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
# Apply the changes without rebooting
sudo sysctl -pFinally, run the build command with an increased memory limit for the Node.js process.
NODE_OPTIONS=--max-old-space-size=4096 bun run buildNote: This configuration helps prevent the build from failing due to out-of-memory errors. 🎆🎇