|
|
|
FROM python:3.13-slim |
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive |
|
ENV LIBTORCH_URL=https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip |
|
ENV PROTOBUF_VERSION=3.13.0 |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y \ |
|
git \ |
|
curl \ |
|
unzip \ |
|
build-essential \ |
|
cmake \ |
|
dos2unix \ |
|
bash \ |
|
cmake \ |
|
make \ |
|
libtorch-dev \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
WORKDIR /tmp |
|
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-3.13.0.tar.gz && \ |
|
tar --no-same-owner -xzf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz && \ |
|
cd protobuf-${PROTOBUF_VERSION} && \ |
|
./configure && make -j$(nproc) && make install && ldconfig |
|
|
|
|
|
RUN mkdir -p /build |
|
|
|
|
|
WORKDIR /build |
|
|
|
COPY pip_requirements pip_requirements |
|
COPY libraries libraries |
|
|
|
COPY src src |
|
COPY include include |
|
COPY CMakeLists.txt /build/CMakeLists.txt |
|
COPY models models |
|
RUN unzip models/model.zip -d models |
|
|
|
|
|
|
|
RUN pip install --no-cache-dir -r pip_requirements/common_requirements.txt |
|
|
|
|
|
RUN mkdir -p libraries/libtorch && \ |
|
curl -L ${LIBTORCH_URL} -o libtorch.zip && \ |
|
unzip -q libtorch.zip -d libraries/ && \ |
|
rm libtorch.zip |
|
|
|
|
|
RUN rm -rf libraries/pybind11 && \ |
|
git clone https://github.com/pybind/pybind11.git libraries/pybind11 && \ |
|
cd libraries/pybind11 && \ |
|
git reset --hard 5ccb9e4 |
|
|
|
|
|
RUN rm -rf libraries/midifile && \ |
|
git clone https://github.com/craigsapp/midifile libraries/midifile && \ |
|
cd libraries/midifile && \ |
|
git reset --hard 838c62c |
|
|
|
|
|
RUN mkdir -p libraries/protobuf/build && \ |
|
protoc --proto_path=libraries/protobuf/src --cpp_out=libraries/protobuf/build libraries/protobuf/src/*.proto |
|
|
|
RUN cp -r /build/libraries/libtorch /opt/ |
|
ENV TORCH_DIR=/opt/libtorch |
|
ENV LD_LIBRARY_PATH=$TORCH_DIR/lib:$LD_LIBRARY_PATH |
|
|
|
|
|
RUN mkdir -p python_lib && \ |
|
cd python_lib && \ |
|
cmake .. -DCMAKE_PREFIX_PATH=$TORCH_DIR && \ |
|
make |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN cp -r /build/python_lib python_lib |
|
RUN cp -r /build/models models |
|
|
|
ENV PYTHONPATH=/app/python_lib |
|
RUN rm -rf /build |
|
RUN python3 -c "import midigpt; print('β
midigpt built and importable')" |
|
|
|
RUN python3 -m pip install --no-cache-dir gradio |
|
|
|
|
|
COPY python_scripts_for_testing/ /app/python_scripts_for_testing |
|
EXPOSE 7860 |
|
WORKDIR /app/python_scripts_for_testing |
|
ENTRYPOINT [ "python", "gradio_app.py" ] |
|
|