Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(back): #1370 add swap to container #1371

Closed
wants to merge 1 commit into from

Conversation

jpverde
Copy link
Collaborator

@jpverde jpverde commented Aug 13, 2024

  • Added swap configuration for the makes container

- Added swap configuration for the makes container

Signed-off-by: John Perez <mrjohnjairo10@gmail.com>
Copy link

sonarcloud bot commented Aug 13, 2024

@@ -30,13 +30,28 @@ __nixpkgs__.dockerTools.buildImage {
__nixpkgs__.gnutar
__nixpkgs__.gzip
__nixpkgs__.nixVersions.nix_2_15
__nixpkgs__.util-linux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unnecessary. You can directly run commands via runCommand in order to configure swap.

'')
# Creat swapfile for the system
(__nixpkgs__.runCommand "swap-file" { } ''
dd if=/dev/zero of=/mnt/swapfile bs=1M count=2048
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work if the container is provided a volume smaller than 2GB?

'')
# Enable swap
(__nixpkgs__.runCommand "swap-enable" { } ''
swapon /mnt/swapfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
swapon /mnt/swapfile
${__nixpkgs__.util-linux}/bin/swapon /mnt/swapfile

@dsalaza4
Copy link
Contributor

Using swap on containers seems to go further than configuring the container itself 🤔

https://kubernetes.io/blog/2023/08/24/swap-linux-beta/

https://docs.docker.com/engine/containers/resource_constraints/#--memory-swap-details

@jpverde jpverde closed this Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants