Skip to main content

Expand your docker-compose.yml file

Project description

Docker Compose Expand

Expand your docker-compose.yml file with this tool.

Install

$ pip3 install --user docker-compose-expand

Usage

Your services in docker-compose.yml file.

version: "3"
services:
  api:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9001:9001"

  products:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9002:9001"

  analysis:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9003:9001"

  monitoring:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9004:9001"

Instead of using the docker-compose tool, define the same services in the docker-compose-expand.yml file and use the docker-compose-expand tool that generates the docker-compose.yml file for your expandable services.

  • You can define variables in loop field or vars field.

  • In the loop field, you can refer to a variable which is in the vars field.

Loop Field

version: "3"
services:
  api:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9001:9001"

expand:
  vars:
  services:
    - name: "{{ name }}"
      service:
        image: ef9n/supervisord:0.1.0
        restart: on-failure
        volumes:
          - "/tmp/{{ name }}/:/opt/{{name}}/"
        ports:
          - "{{ port }}:9001"
      loop:
        - name: products
          port: 9002
        - name: analysis
          port: 9003
        - name: monitoring
          port: 9004

Vars Field

# Vars Field
version: "3"
services:
  api:
    image: ef9n/supervisord:0.1.0
    restart: on-failure
    ports:
      - "9001:9001"

expand:
  vars:
    supervisors:
      - name: products
        port: 9002
      - name: analysis
        port: 9003
      - name: monitoring
        port: 9004
  services:
    - name: "{{ name }}"
      service:
        image: ef9n/supervisord:0.1.0
        restart: on-failure
        volumes:
          - "/tmp/{{ name }}/:/opt/{{name}}/"
        ports:
          - "{{ port }}:9001"
      loop: "{{ supervisors }}"

Examples

Look up the examples directory.

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for docker-compose-expand, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size docker_compose_expand-0.1.0-py3-none-any.whl (6.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size docker-compose-expand-0.1.0.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page