import sys

lines = open(sys.argv[1]).readlines()

block = '''
  ace-step:
    build:
      context: ./services/ace-step
    image: sudx/ace-step:latest
    container_name: ace-step
    restart: "no"
    volumes:
      - /home/fabian/sudx-ai/models/ace-step:/models/ace-step:ro
      - /home/fabian/sudx-ai/outputs/music:/outputs/music
    ports:
      - "8076:8076"
    environment:
      - PYTHONUNBUFFERED=1
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://localhost:8076/health"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 300s
    deploy:
      resources:
        limits:
          memory: 14G

'''

for i, line in enumerate(lines):
    if line.strip() == 'sudx-dashboard:':
        lines.insert(i, block)
        break

open(sys.argv[1], 'w').writelines(lines)
print("Done - ace-step inserted before sudx-dashboard")
