diff --git a/README.md b/README.md index ddded49..a58c0e6 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ If a feature is missing, please feel free to [create an issue](https://github.co | [`shm_size`](https://docs.docker.com/compose/compose-file/05-services/#shm_size) | ✅ | | [`runtime`](https://docs.docker.com/compose/compose-file/05-services/#runtime) | ✅ | | [`security_opt`](https://docs.docker.com/compose/compose-file/05-services/#security_opt) | ✅ | +| [`command`](https://docs.docker.com/compose/compose-file/05-services/#command) | ✅ | #### [`networks`](https://docs.docker.com/compose/compose-file/06-networks/) diff --git a/compose.go b/compose.go index ef5fbcf..204e83e 100644 --- a/compose.go +++ b/compose.go @@ -228,6 +228,7 @@ func (g *Generator) buildNixContainer(service types.ServiceConfig) (*NixContaine Volumes: make(map[string]string), SystemdConfig: systemdConfig, LogDriver: "journald", // This is the NixOS default + Command: service.Command, } if g.IncludeEnvFiles { diff --git a/nix.go b/nix.go index 404a4bb..b96d2fe 100644 --- a/nix.go +++ b/nix.go @@ -117,6 +117,7 @@ type NixContainer struct { ExtraOptions []string SystemdConfig *NixContainerSystemdConfig User string + Command []string } func (c *NixContainer) Unit() string { diff --git a/templates/container.nix.tmpl b/templates/container.nix.tmpl index 7106971..1886a26 100644 --- a/templates/container.nix.tmpl +++ b/templates/container.nix.tmpl @@ -33,6 +33,10 @@ virtualisation.oci-containers.containers."{{.Name}}" = { ]; {{- end}} + {{- if .Command}} + cmd = [{{range .Command}} "{{.}}" {{end}}]; + {{- end}} + {{- if .Labels}} labels = { {{- range $k, $v := .Labels}} diff --git a/testdata/TestDocker_EnvFilesOnly_out.nix b/testdata/TestDocker_EnvFilesOnly_out.nix index 60c581a..7096b36 100644 --- a/testdata/TestDocker_EnvFilesOnly_out.nix +++ b/testdata/TestDocker_EnvFilesOnly_out.nix @@ -18,6 +18,7 @@ "/var/volumes/jellyseerr:/app/config:rw" "books:/books:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestDocker_RemoveVolumes_out.nix b/testdata/TestDocker_RemoveVolumes_out.nix index 8e65105..d2758d4 100644 --- a/testdata/TestDocker_RemoveVolumes_out.nix +++ b/testdata/TestDocker_RemoveVolumes_out.nix @@ -20,6 +20,7 @@ "/var/volumes/jellyseerr:/app/config:rw" "books:/books:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestDocker_SystemdMount_out.nix b/testdata/TestDocker_SystemdMount_out.nix index b8a4dca..b63b4d0 100644 --- a/testdata/TestDocker_SystemdMount_out.nix +++ b/testdata/TestDocker_SystemdMount_out.nix @@ -20,6 +20,7 @@ "/var/volumes/jellyseerr:/app/config:rw" "books:/books:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestDocker_WithProject_out.nix b/testdata/TestDocker_WithProject_out.nix index 7dd97d7..8ec5a9d 100644 --- a/testdata/TestDocker_WithProject_out.nix +++ b/testdata/TestDocker_WithProject_out.nix @@ -20,6 +20,7 @@ "/var/volumes/jellyseerr:/app/config:rw" "books:/books:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestDocker_out.nix b/testdata/TestDocker_out.nix index e03aa56..3ec64b4 100644 --- a/testdata/TestDocker_out.nix +++ b/testdata/TestDocker_out.nix @@ -20,6 +20,7 @@ "/var/volumes/jellyseerr:/app/config:rw" "books:/books:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestPodman_WithProject_out.nix b/testdata/TestPodman_WithProject_out.nix index 67abf34..f26bf7d 100644 --- a/testdata/TestPodman_WithProject_out.nix +++ b/testdata/TestPodman_WithProject_out.nix @@ -25,6 +25,7 @@ "/mnt/media/Books:/books:rw" "/var/volumes/jellyseerr:/app/config:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/TestPodman_out.nix b/testdata/TestPodman_out.nix index d46170d..12eb6ca 100644 --- a/testdata/TestPodman_out.nix +++ b/testdata/TestPodman_out.nix @@ -25,6 +25,7 @@ "/mnt/media/Books:/books:rw" "/var/volumes/jellyseerr:/app/config:rw" ]; + cmd = [ "ls" "-la" "/" ]; labels = { "traefik.enable" = "true"; "traefik.http.routers.jellyseerr.middlewares" = "chain-authelia@file"; diff --git a/testdata/docker-compose.yml b/testdata/docker-compose.yml index 93e1b16..0260c97 100644 --- a/testdata/docker-compose.yml +++ b/testdata/docker-compose.yml @@ -121,6 +121,7 @@ services: max-size: 10m max-file: "3" compress: "true" + command: ls -la / restart: unless-stopped photoprism-mariadb: image: docker.io/library/mariadb:10.9