Skip to content

Commit 796535f

Browse files
chore(infra): add swap file configuration to prevent memory issues
Add a 2GB swap file to the EC2 instance setup to avoid memory crashes during npm install/build operations on t4g.micro instances. This ensures reliable package installation and build processes in memory-constrained environments.
1 parent b7de08a commit 796535f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

apps/infra/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ sudo systemctl enable docker
8383
sudo systemctl start docker
8484
sudo usermod -aG docker ec2-user
8585
86+
# Configuração de Swap File (Para evitar travamentos de memória na t4g.micro durante o npm install/build)
87+
sudo dd if=/dev/zero of=/swapfile bs=128M count=16
88+
sudo chmod 600 /swapfile
89+
sudo mkswap /swapfile
90+
sudo swapon /swapfile
91+
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
92+
8693
# Instala Docker Compose V2 e Docker Buildx (necessário para o Compose V2)
8794
mkdir -p /usr/local/lib/docker/cli-plugins
8895
curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-aarch64 -o /usr/local/lib/docker/cli-plugins/docker-compose

0 commit comments

Comments
 (0)