Skip to content

Commit

Permalink
support container command setting
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Dec 2, 2023
1 parent afbfd8d commit da717b5
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
1 change: 1 addition & 0 deletions compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type NixContainer struct {
ExtraOptions []string
SystemdConfig *NixContainerSystemdConfig
User string
Command []string
}

func (c *NixContainer) Unit() string {
Expand Down
4 changes: 4 additions & 0 deletions templates/container.nix.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ virtualisation.oci-containers.containers."{{.Name}}" = {
];
{{- end}}

{{- if .Command}}
cmd = [{{range .Command}} "{{.}}" {{end}}];
{{- end}}

{{- if .Labels}}
labels = {
{{- range $k, $v := .Labels}}
Expand Down
1 change: 1 addition & 0 deletions testdata/TestDocker_EnvFilesOnly_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestDocker_RemoveVolumes_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestDocker_SystemdMount_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestDocker_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestDocker_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestPodman_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/TestPodman_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions testdata/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da717b5

Please sign in to comment.