Skip to content

Commit

Permalink
Merge pull request #230 from Crypto-TII/fix/docker-image-m1
Browse files Browse the repository at this point in the history
Fix/docker image m1
  • Loading branch information
peacker authored May 15, 2024
2 parents a506095 + 0c941f7 commit e1c9e25
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rundocker: builddocker
sh -c "cd /home/sage/tii-claasp && make install && cd /home/sage/tii-claasp && exec /bin/bash"

builddocker-m1:
docker build --build-arg="GUROBI_ARCH=armlinux64" -f docker/Dockerfile --platform linux/aarch64 --target claasp-base -t $(DOCKER_IMG_NAME) .
docker build -f docker/Dockerfile --platform linux/x86_64 --target claasp-base -t $(DOCKER_IMG_NAME) .

rundocker-m1: builddocker-m1
docker run -i -p 8888:8888 --mount type=bind,source=`pwd`,target=/home/sage/tii-claasp -t $(DOCKER_IMG_NAME) \
Expand Down Expand Up @@ -95,6 +95,3 @@ copyright: install

local-installation:
./configure.sh

local-installation-m1:
./configure.sh armlinux64
2 changes: 1 addition & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

apt-get -qq update
apt-get install -y python3
python3 create_bash_script.py $1
python3 create_bash_script.py
chmod +x dependencies_script.sh
./dependencies_script.sh
source ~/.bashrc
Expand Down
18 changes: 6 additions & 12 deletions create_bash_script.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sys

gurobi_arch = sys.argv[1] or 'linux64'

with open('docker/Dockerfile', 'r') as f:
dockerfile_lines = f.readlines()

Expand All @@ -10,6 +8,10 @@
environment_variables = []
for line in dockerfile_lines:
line = line.strip()

if line.startswith("FROM claasp-base AS claasp-lib"):
break

is_a_comment = line.startswith('#')
is_split_command = line.endswith('\\')
if not line or is_a_comment:
Expand All @@ -21,11 +23,7 @@
docker_command += line
bash_instruction = ''
if docker_command.startswith('RUN'):
command = docker_command.split('RUN')[1].strip()
if 'GUROBI_ARCH' in command:
bash_instruction = command.replace('${GUROBI_ARCH}', gurobi_arch)
else:
bash_instruction = command
bash_instruction = docker_command.split('RUN')[1].strip()
elif docker_command.startswith('ENV'):
command = docker_command.split('ENV')[1].strip()
environment_variable = command.split('=')[0]
Expand All @@ -34,11 +32,7 @@
bash_instruction = f'export {command}'
elif docker_command.startswith('ARG'):
command = docker_command.split('ARG')[1].strip()
bash_instruction = 'export '
if 'GUROBI_ARCH' in command:
bash_instruction += f'GUROBI_ARCH={gurobi_arch}'
else:
bash_instruction += command
bash_instruction = f'export {command}'
elif docker_command.startswith('WORKDIR'):
directory = docker_command.split('WORKDIR')[1].strip()
if directory != '/home/sage/tii-claasp':
Expand Down
9 changes: 4 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM ubuntu:22.04 AS claasp-base

ARG DEBIAN_FRONTEND=noninteractive
ARG GUROBI_ARCH=linux64
ARG COPY_CLAASP_LIBRARY=false
ARG INSTALL_CLAASP_LIBRARY=false

Expand Down Expand Up @@ -30,11 +29,11 @@ COPY docker/sitecustomize.py /usr/lib/python3.10/sitecustomize.py

WORKDIR /opt

RUN wget https://packages.gurobi.com/10.0/gurobi10.0.0_${GUROBI_ARCH}.tar.gz \
&& tar -xf gurobi10.0.0_${GUROBI_ARCH}.tar.gz \
&& rm gurobi10.0.0_${GUROBI_ARCH}.tar.gz
RUN wget https://packages.gurobi.com/10.0/gurobi10.0.0_linux64.tar.gz \
&& tar -xf gurobi10.0.0_linux64.tar.gz \
&& rm gurobi10.0.0_linux64.tar.gz

ENV GUROBI_HOME="/opt/gurobi1000/${GUROBI_ARCH}"
ENV GUROBI_HOME="/opt/gurobi1000/linux64"
ENV PATH="${PATH}:${GUROBI_HOME}/bin"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

Expand Down
4 changes: 1 addition & 3 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ To install the dependencies manually, you can do it through make command or exec
root directory of the project.

#### Make command
You need to have `make` installed for this execution.
- For m1 macs, run ```make local-installation-m1```
- For other machines, run ```make local-installation```
You need to have `make` installed for this execution. Run ```make local-installation```

#### Script execution
- For m1 macs, run ```./configure.sh armlinux64```
Expand Down

0 comments on commit e1c9e25

Please sign in to comment.