# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: SunoApi
spec:
    description: Suno API Unofficial Suno AI client, currently supports the generation of music, access to music information and other functions.
    coverImage: https://sunoapi.net/images/sunoapi.jpg
    icon: https://avatars.githubusercontent.com/u/164985398
    tags:
        - API
        - Automation
        - Website
    readme: |-
        ### Debug

        #### Python local debug running

        - Clone source code

        ```bash
        git clone https://github.com/SunoApi/SunoApi.git
        ```


        - Installation dependencies

        ```bash
        cd SunoApi
        pip3 install -r requirements.txt
        ```

        - .env environment variable, Image recognition requires the use of the gpt-4-vision review model, which can use OpenAI interfaces or replace them with other commonly used interfaces

        ```bash
        OPENAI_BASE_URL = https://chatplusapi.cn
        OPENAI_API_KEY = sk-xxxxxxxxxxxxxxxxxxxx
        WEB_SITE_URL = http://localhost:8501
        ```


        - Start the project, please refer to the Streamlit documentation for details on Streamlit

        ```bash
        streamlit run main.py --server.maxUploadSize=2
        ```

        ### Deploy

        #### Docker local one-click deployment

        ```bash
        docker run -d \
          --name sunoapi \
          --restart always \
          -p 8501:8501 \
          -v ./sunoapi.db:/app/sunoapi.db \
          -v ./images/upload:/app/images/upload \
          -e OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx \
          -e OPENAI_BASE_URL=https://api.openai.com  \
          -e WEB_SITE_URL=http://localhost:8501  \
          sunoapi/sunoapi:latest
        ```

        ##### Attention: It is necessary to http://localhost:8501 Replace with the actual address you can access, and the final uploaded image file will pass through http://domain.com/images/upload/xxxxxx.jpg The format can be accessed, otherwise OpenAI cannot access the image you uploaded and cannot recognize its content. Therefore, the function of uploading images to generate music will not be available.


        #### Docker local compilation and deployment

        ```bash
        docker compose build && docker compose up
        ```

        #### Dockerfile

        ```docker
        FROM python:3.10-slim-buster

        WORKDIR /app

        COPY requirements.txt ./
        RUN --mount=type=cache,target=/root/.cache/pip \
            pip install -r requirements.txt --no-cache-dir

        COPY . .

        EXPOSE 8501
        CMD [ "nohup", "streamlit", "run", "main.py", "--server.maxUploadSize=2" ]
        ```

        #### Docker pull image deployment

        ```bash
        docker-compose pull && docker-compose up -d
        ```

        #### docker-compose.yml

        ```docker
        version: '3.2'

        services:
          sunoapi:
            image: sunoapi/sunoapi:latest
            container_name: sunoapi
            ports:
              - "8501:8501"
            volumes:
              - ./sunoapi.db:/app/sunoapi.db
              - ./images/upload:/app/images/upload
            environment:
              - TZ=Asia/Shanghai
              - OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
              - OPENAI_BASE_URL=https://api.openai.com
              - WEB_SITE_URL=http://localhost:8501
            restart: always
        ```

        ##### Note: To pull image deployment, you need to download sunoapi.db from the project and transfer it to your docker-compose.yml file directory. Otherwise, Docker startup will prompt that the file cannot be mounted.
    services:
        - name: sunoapi
          template: GIT
          spec:
            source:
                source: GITHUB
                repo: 785824241
                branch: main
