containers / podlet

Generate Podman Quadlet files from a Podman command, compose file, or existing object
https://crates.io/crates/podlet
Mozilla Public License 2.0
318 stars 10 forks source link

Compose: support for non-string label values #62

Closed jinks closed 2 months ago

jinks commented 4 months ago

Currently podlet does not support labels in compose files which excludes the conversion of a vast list of valid compose files.

Error:

% podlet compose
Error: 
   0: File `docker-compose.yaml` is not a valid compose file
   1: services.code-server: data did not match any variant of untagged enum Labels at line 24 column 5

Location:
   src/cli/compose.rs:61

compose file:


version: '3.8'

services:
 code-server:
    container_name: code-server
    image: docker.io/codercom/code-server:latest
    environment:
      DOCKER_USER: jinks
    volumes:
      - code_config:/home/coder/.config
      - code_local:/home/coder/.local
      - code_workspace:/home/coder/project
    expose:
      - 8080/tcp 
    labels:
      traefik.enable: true
      traefik.docker.network: traefik
      traefik.http.services.codeserver.loadbalancer.server.port: 8080
      traefik.http.routers.codeserver.rule: "Host(`vscode.example.com`)"
      traefik.http.routers.codeserver.entrypoints: websecure
      traefik.http.routers.codeserver.tls: true
    networks:
      - traefik
    restart: unless-stopped # Keep the container running unless manually stopped
k9withabone commented 4 months ago

In the current implementation, label values must be strings. For now, as a workaround, you can surround the non-string values with quotes to make them strings. For example, your compose file would look like:

version: '3.8'

services:
 code-server:
    container_name: code-server
    image: docker.io/codercom/code-server:latest
    environment:
      DOCKER_USER: jinks
    volumes:
      - code_config:/home/coder/.config
      - code_local:/home/coder/.local
      - code_workspace:/home/coder/project
    expose:
      - 8080/tcp 
    labels:
      traefik.enable: "true"
      traefik.docker.network: traefik
      traefik.http.services.codeserver.loadbalancer.server.port: "8080"
      traefik.http.routers.codeserver.rule: "Host(`vscode.example.com`)"
      traefik.http.routers.codeserver.entrypoints: websecure
      traefik.http.routers.codeserver.tls: "true"
    networks:
      - traefik
    restart: unless-stopped # Keep the container running unless manually stopped

This will be fixed in the future.

k9withabone commented 4 months ago

This issue is blocked on #63, which should also fix this issue.