From 4c4d3196adf1b198dce5254b190a895ac854c97a Mon Sep 17 00:00:00 2001 From: Assil Ksiksi Date: Tue, 28 Nov 2023 14:38:06 -0500 Subject: [PATCH] add support for shm_size --- README.md | 1 + compose.go | 4 ++++ testdata/TestDocker_EnvFilesOnly_out.nix | 1 + testdata/TestDocker_RemoveVolumes_out.nix | 1 + testdata/TestDocker_SystemdMount_out.nix | 1 + testdata/TestDocker_WithProject_out.nix | 1 + testdata/TestDocker_out.nix | 1 + testdata/TestPodman_WithProject_out.nix | 1 + testdata/TestPodman_out.nix | 1 + testdata/docker-compose.yml | 1 + 10 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 1194ae7..4eb10c7 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ If a feature is missing, please feel free to [create an issue](https://github.co | [`privileged`](https://docs.docker.com/compose/compose-file/05-services/#privileged) | ✅ | | [`extra_hosts`](https://docs.docker.com/compose/compose-file/05-services/#extra_hosts) | ✅ | | [`sysctls`](https://docs.docker.com/compose/compose-file/05-services/#sysctls) | ✅ | +| [`shm_size`](https://docs.docker.com/compose/compose-file/05-services/#shm_size) | ✅ | #### [`networks`](https://docs.docker.com/compose/compose-file/06-networks/) diff --git a/compose.go b/compose.go index 0e524f1..25bef87 100644 --- a/compose.go +++ b/compose.go @@ -373,6 +373,10 @@ func (g *Generator) buildNixContainer(service types.ServiceConfig) (*NixContaine c.ExtraOptions = append(c.ExtraOptions, fmt.Sprintf("--sysctl=%s=%s", name, value)) } + if service.ShmSize != 0 { + c.ExtraOptions = append(c.ExtraOptions, fmt.Sprintf("--shm-size=%d", service.ShmSize)) + } + // Compose defaults to "json-file", so we'll treat _any_ "json-file" setting as a default. // Users can override this behavior via CLI. // diff --git a/testdata/TestDocker_EnvFilesOnly_out.nix b/testdata/TestDocker_EnvFilesOnly_out.nix index e1a2eb5..e4589c0 100644 --- a/testdata/TestDocker_EnvFilesOnly_out.nix +++ b/testdata/TestDocker_EnvFilesOnly_out.nix @@ -181,6 +181,7 @@ "--network-alias=transmission" "--network=myproject-something" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestDocker_RemoveVolumes_out.nix b/testdata/TestDocker_RemoveVolumes_out.nix index 352a539..fc2e371 100644 --- a/testdata/TestDocker_RemoveVolumes_out.nix +++ b/testdata/TestDocker_RemoveVolumes_out.nix @@ -206,6 +206,7 @@ "--network-alias=transmission" "--network=myproject-something" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestDocker_SystemdMount_out.nix b/testdata/TestDocker_SystemdMount_out.nix index 0ab51c2..2edaf90 100644 --- a/testdata/TestDocker_SystemdMount_out.nix +++ b/testdata/TestDocker_SystemdMount_out.nix @@ -212,6 +212,7 @@ "--network-alias=transmission" "--network=myproject-something" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestDocker_WithProject_out.nix b/testdata/TestDocker_WithProject_out.nix index 74f8cd6..dd8742b 100644 --- a/testdata/TestDocker_WithProject_out.nix +++ b/testdata/TestDocker_WithProject_out.nix @@ -206,6 +206,7 @@ "--network-alias=transmission" "--network=myproject-something" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestDocker_out.nix b/testdata/TestDocker_out.nix index e116e80..271463b 100644 --- a/testdata/TestDocker_out.nix +++ b/testdata/TestDocker_out.nix @@ -202,6 +202,7 @@ "--network-alias=transmission" "--network=myproject-something" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestPodman_WithProject_out.nix b/testdata/TestPodman_WithProject_out.nix index 946bf62..5339c1e 100644 --- a/testdata/TestPodman_WithProject_out.nix +++ b/testdata/TestPodman_WithProject_out.nix @@ -196,6 +196,7 @@ "--network-alias=transmission" "--network=myproject-something:alias=my-torrent-client" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/TestPodman_out.nix b/testdata/TestPodman_out.nix index be6c055..9102806 100644 --- a/testdata/TestPodman_out.nix +++ b/testdata/TestPodman_out.nix @@ -192,6 +192,7 @@ "--network-alias=transmission" "--network=myproject-something:alias=my-torrent-client" "--privileged" + "--shm-size=67108864" "--sysctl=net.ipv6.conf.all.disable_ipv6=0" ]; }; diff --git a/testdata/docker-compose.yml b/testdata/docker-compose.yml index 0556bbd..a6f2404 100644 --- a/testdata/docker-compose.yml +++ b/testdata/docker-compose.yml @@ -56,6 +56,7 @@ services: - "abc:93.184.216.34" depends_on: - sabnzbd + shm_size: 64m environment: TZ: ${TIMEZONE} PUID: ${PUID}