#  SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#  SPDX-License-Identifier: Apache-2.0
#  #
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#  #
#  http://www.apache.org/licenses/LICENSE-2.0
#  #
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

VERSION 0.8

uv-source:
    FROM ghcr.io/astral-sh/uv:latest
    SAVE ARTIFACT /uv

uv-base:
    FROM python:3.12-slim
    COPY +uv-source/uv /bin/uv
    RUN uv venv
    ENV PATH="/app/.venv/bin:$PATH"
    RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
    WORKDIR /app
    COPY uv.lock pyproject.toml README.md /app
    RUN uv sync --frozen --no-install-project --no-dev --no-install-workspace --no-editable

docker:
    ARG DOCKER_SERVER=my-registry
    ARG IMAGE_TAG=latest
    ARG IMAGE=dynamo-api-store
    FROM +uv-base
    # Copy project files
    COPY ai_dynamo_store ai_dynamo_store
    RUN uv pip install .
    ENTRYPOINT ["ai-dynamo-store"]
    SAVE IMAGE --push $DOCKER_SERVER/$IMAGE:$IMAGE_TAG