diff --git a/compose_viz/parser.py b/compose_viz/parser.py index 2440bce..757d3ed 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -42,12 +42,19 @@ class Parser: service_image: Optional[str] = None if service.get("build"): if type(service["build"]) is str: - service_image = "build from " + service["build"] + service_image = f"build from '{service['build']}'" elif type(service["build"]) is dict: - assert service["build"].get("context"), "Missing build context, aborting." - service_image = "build from " + str(service["build"]["context"]) - elif service.get("image"): - service_image = service["image"] + if service["build"].get("context") and service["build"].get("dockerfile"): + service_image = ( + f"build from '{service['build']['context']}' using '{service['build']['dockerfile']}'" + ) + elif service["build"].get("context"): + service_image = f"build from '{service['build']['context']}'" + if service.get("image"): + if service_image: + service_image += ", image: " + service["image"] + else: + service_image = service["image"] service_networks: List[str] = [] if service.get("networks"): diff --git a/examples/full-stack-node-app/docker-compose.yml b/examples/full-stack-node-app/docker-compose.yml index c3602de..5e5387f 100644 --- a/examples/full-stack-node-app/docker-compose.yml +++ b/examples/full-stack-node-app/docker-compose.yml @@ -23,8 +23,9 @@ services: volumes: - ./api:/usr/src depends_on: - - postgres + - db - adminer + - redis command: ["npm", "start"] frontend: @@ -38,22 +39,34 @@ services: - 3000 ports: - 3000:3000 - environment: - - REACT_APP_ENV=development - - BACKEND=api:8000 - - HTTPS=true - - NODE_PATH=/usr/src/ volumes: - ./frontend:/usr/src depends_on: - api command: ["npm", "start"] - postgres: - image: postgres + db: + image: "awesome/db" + extends: + service: postgres + from: postgres.yml restart: always + volumes: + - "db-data:/data" + - type: bind + source: /var/run/postgres/postgres.sock + target: /var/run/postgres/postgres.sock + + redis: + image: "awesome/redis" + restart: always + expose: + - 6379 adminer: - image: adminer + image: "awesome/adminer" ports: - 8080:8080 + + volumes: + db-data: diff --git a/examples/full-stack-node-app/postgres.yml b/examples/full-stack-node-app/postgres.yml new file mode 100644 index 0000000..cb6c45e --- /dev/null +++ b/examples/full-stack-node-app/postgres.yml @@ -0,0 +1,5 @@ +version: "3.9" + +services: + postgres: + image: awesome/postgres diff --git a/examples/non-normative/docker-compose.yml b/examples/non-normative/docker-compose.yml new file mode 100644 index 0000000..2ed41b9 --- /dev/null +++ b/examples/non-normative/docker-compose.yml @@ -0,0 +1,47 @@ +services: + frontend: + image: awesome/webapp + networks: + - front-tier + - back-tier + + monitoring: + image: awesome/monitoring + networks: + - admin + + + backend: + networks: + back-tier: + aliases: + - database + admin: + aliases: + - mysql + volumes: + - type: volume + source: db-data + target: /data + volume: + nocopy: true + - type: bind + source: /var/run/postgres/postgres.sock + target: /var/run/postgres/postgres.sock + depends_on: + - monitoring + extends: + service: frontend + ports: + - "8000:5010" + links: + - "db:database" + db: + image: postgres + +networks: + front-tier: + back-tier: + admin: +volumes: + db-data: