services:
  # Database service with build
  db:
    pull_policy: build
    build:
      dockerfile_inline: |
        FROM alpine
        RUN echo "DB built at $(date)" > /db-build.txt
        CMD sleep 3600

  # API service that depends on db
  api:
    pull_policy: build
    build:
      dockerfile_inline: |
        FROM alpine
        RUN echo "API built at $(date)" > /api-build.txt
        CMD sleep 3600
    depends_on:
      - db

  # App service that depends on api (which depends on db)
  app:
    pull_policy: build
    build:
      dockerfile_inline: |
        FROM alpine
        RUN echo "App built at $(date)" > /app-build.txt
        CMD echo "App running"
    depends_on:
      - api

