mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Merge pull request #161 from Hestia-Homes/main
trying to get mip working in arm64
This commit is contained in:
commit
bbd2722ed7
1 changed files with 21 additions and 9 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
# Some additional work is required to get mip to run on arm64 architecture.
|
||||||
|
# This is because the mip library relies on the CBC solver, which is not available for arm64.
|
||||||
|
# https://python-mip.readthedocs.io/en/latest/install.html
|
||||||
|
|
||||||
# Pull base image
|
# Pull base image
|
||||||
FROM arm64v8/python:3.10.12-slim-bullseye as build-image
|
FROM arm64v8/python:3.10.12-slim-bullseye as build-image
|
||||||
|
|
||||||
|
|
@ -6,21 +10,24 @@ ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
# Set work directory to the root of your project
|
# Set work directory to the root of your project
|
||||||
WORKDIR var/task/Model
|
WORKDIR /var/task/Model
|
||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies
|
||||||
#RUN apt-get update && apt-get install -y netcat-openbsd
|
RUN apt-get update && apt-get install -y gcc g++ gfortran libgfortran-9-dev liblapack-dev libamd2 libcholmod3 \
|
||||||
|
libmetis-dev libsuitesparse-dev libnauty2-dev git wget
|
||||||
|
|
||||||
|
# Compile CBC for arm64
|
||||||
|
RUN mkdir -p ~/build && cd ~/build \
|
||||||
|
&& wget -nH https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew \
|
||||||
|
&& bash coinbrew fetch Cbc@master --no-prompt \
|
||||||
|
&& bash coinbrew build Cbc@master --no-prompt --prefix=/home/root/prog/ --tests=none --enable-cbc-parallel --enable-relocatable
|
||||||
|
|
||||||
# Install python dependencies
|
# Install python dependencies
|
||||||
COPY ./backend/requirements/base.txt ./backend/requirements/base.txt
|
COPY ./backend/requirements/base.txt ./backend/requirements/base.txt
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip \
|
||||||
# Install and clean up temp caches
|
&& pip install -r backend/requirements/base.txt && rm -rf /root/.cache
|
||||||
RUN pip install -r backend/requirements/base.txt && rm -rf /root/.cache
|
|
||||||
|
|
||||||
# Since we are not using a base AWS image, there is some additional setup required. We need to set up the runtime
|
# Install the AWS Lambda RIC
|
||||||
# interface client
|
|
||||||
# https://docs.aws.amazon.com/lambda/latest/dg/python-image.html#python-image-clients
|
|
||||||
# Additionally install the AWS Lambda RIC
|
|
||||||
RUN pip install awslambdaric
|
RUN pip install awslambdaric
|
||||||
|
|
||||||
# Second stage: "runtime-image"
|
# Second stage: "runtime-image"
|
||||||
|
|
@ -31,6 +38,11 @@ WORKDIR /var/task/Model
|
||||||
|
|
||||||
# Copy the python dependencies from the build-image
|
# Copy the python dependencies from the build-image
|
||||||
COPY --from=build-image /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
|
COPY --from=build-image /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
|
||||||
|
COPY --from=build-image /home/root/prog/lib/ /usr/local/lib/
|
||||||
|
|
||||||
|
# Set environment variable for mip to use custom CBC binaries
|
||||||
|
ENV PMIP_CBC_LIBRARY="/usr/local/lib/libCbcSolver.so"
|
||||||
|
ENV LD_LIBRARY_PATH="/usr/local/lib/":$LD_LIBRARY_PATH
|
||||||
|
|
||||||
# Copy project files
|
# Copy project files
|
||||||
COPY ./backend/ ./backend
|
COPY ./backend/ ./backend
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue