#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.
#

FROM quay.io/pypa/manylinux2014_x86_64:latest

ENV CMAKE_POLICY_VERSION_MINIMUM=3.5

# build cpp sdk

COPY dataproxy-sdk-cpp /workspace/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp
WORKDIR /workspace/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp

RUN ./build_third_party.sh
RUN ./build.sh

# prepare python sdk source tree

COPY dataproxy-sdk-python /workspace/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python
WORKDIR /workspace/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python

RUN cp -r ../dataproxy-sdk-cpp ./

# build python sdk wheels using PEP-517

RUN /opt/python/cp38-cp38/bin/python3 -m build --sdist

RUN /opt/python/cp38-cp38/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp39-cp39/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp310-cp310/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp311-cp311/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp312-cp312/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp313-cp313/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz
RUN /opt/python/cp314-cp314/bin/python3 -m pip wheel --no-deps --wheel-dir dist dist/*.tar.gz

RUN auditwheel repair dist/*.whl

# now target sdist is in dist/, and target wheels are in wheelhouse/. ignore wheels in dist/.
