Skip to content

Instantly share code, notes, and snippets.

@dipspb
Last active January 1, 2024 11:24
Show Gist options
  • Save dipspb/a08258117f5bbc4fc14712ac2f98f66b to your computer and use it in GitHub Desktop.
Save dipspb/a08258117f5bbc4fc14712ac2f98f66b to your computer and use it in GitHub Desktop.

Revisions

  1. dipspb revised this gist Oct 13, 2023. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ x-default-environment: &x-default-environment
    HELLO: Hi! I am
    SVC_NAME: service-X-DEFAULT

    # sequence merge example
    # sequence merge example, there are no "- " prefixes
    x-default-volumes: &x-default-volumes |-
    ./a:/tmp/A
    ./b:/tmp/B
    @@ -66,4 +66,3 @@ services:
    # sequence merge example
    - *x-default-volumes
    - ./c:/tmp/C

  2. dipspb created this gist Oct 13, 2023.
    69 changes: 69 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    version: "3.4"

    # Prepare files for this example:
    # mkdir -p ./a ./b ./c && touch a/a.txt b/b.txt c/c.txt

    x-default-image: &x-default-image
    image: ubuntu

    x-default-cmd: &x-default-cmd
    command: bash -c "echo $${HELLO} $${SVC_NAME} ; ls -al /tmp/*"

    # map merge example
    x-default-environment: &x-default-environment
    HELLO: Hi! I am
    SVC_NAME: service-X-DEFAULT

    # sequence merge example
    x-default-volumes: &x-default-volumes |-
    ./a:/tmp/A
    ./b:/tmp/B

    services:

    service-A:
    <<:
    - *x-default-image
    - *x-default-cmd
    profiles:
    - a
    - both
    environment:
    # map merge example
    <<: *x-default-environment
    SVC_NAME: service-A
    volumes:
    # sequence merge example
    - *x-default-volumes

    service-B:
    <<: [*x-default-image, *x-default-cmd]
    profiles:
    - b
    - both
    environment:
    <<: *x-default-environment
    SVC_NAME: service-B
    volumes:
    # sequence merge example
    - *x-default-volumes

    depends_on:
    service-A:
    condition: service_completed_successfully
    links:
    - service-A

    service-C:
    <<: [*x-default-image, *x-default-cmd]
    profiles:
    - a
    - c
    environment:
    <<: *x-default-environment
    SVC_NAME: service-C
    volumes:
    # sequence merge example
    - *x-default-volumes
    - ./c:/tmp/C