-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile_Flatzingo
73 lines (60 loc) · 3.11 KB
/
Dockerfile_Flatzingo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#------------------------------------------------------------------------------#
# This file contains the setup for the flatzingo submission to the MiniZinc
# challenge. It uses two stages. In the first stage, it builds/compiles
# flatzingo in the same OS as the MiniZinc Challenge docker image. The second
# stage extends the provided MiniZinc Challenge docker image by copying the
# flatzingo executable and its MiniZinc library across from the first stage as
# well as installing missing libraries for running flatzingo if necessary.
# Note that you do not have to use multi stages. Everything can be done in a
# one stage build. However, Note that the statements ADD, RUN, and COPY can
# add image layers, which can increase the size of the layer you have to
# upload.
#------------------------------------------------------------------------------#
# 1. Stage: Compilation of flatzingo in a Build Stage
# Using the same image as for the MiniZinc Challenge
FROM minizinc/mznc2022:latest AS builder
ENV PATH="/install/bin:${PATH}"
ARG PATH="/install/bin:${PATH}"
# Updating & installing necessary packages
RUN apt-get update -y && apt-get install -y \
build-essential \
git \
curl
RUN curl https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN git clone https://github.com/potassco/fzn2lp.git && \
cd fzn2lp && \
git checkout v0.1.6 && \
cargo build --release && \
mkdir -p /install/bin && \
cp target/release/fzn2lp /install/bin/
RUN git clone https://github.com/potassco/flatzingo.git
#------------------------------------------------------------------------------#
# 2. Stage: Setup of flatzingo in the MiniZinc Challenge docker image
#
# Using the MiniZinc Challenge docker image
FROM minizinc/mznc2022:latest
ENV PATH="/install/bin:${PATH}"
# Installing python for wrapper script
# clingcon 9fe422086ff60a1d6c480dc6cdee3271adfe9c4a
RUN apt-get update -y && apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
add-apt-repository ppa:potassco/wip && \
apt-get install -y python3-pip clingcon=5.2.1-focal4 && \
pip3 install --extra-index-url https://test.pypi.org/simple/ clingcon==5.2.1-post3
# Copy fzn2lp's executable from the previous stage across
COPY --from=builder /install /install
# Copy flatzingo's executable from the previous stage across
RUN mkdir -p /flatzingo/encodings
COPY --from=builder /minizinc/flatzingo/encodings/* /flatzingo/encodings/
COPY --from=builder /minizinc/flatzingo/fzn-flatzingo.py /flatzingo/
COPY --from=builder /minizinc/flatzingo/fzn-flatzingo.sh /flatzingo/fzn-flatzingo.sh
RUN chmod a+x /flatzingo/fzn-flatzingo.sh
# Copy flatzingo's MiniZinc library from the previous stage across
COPY --from=builder /minizinc/flatzingo/share/minizinc/flatzingo/* /flatzingo/flatzingo-lib/
# Copy flatzingo's configuration file
COPY --from=builder /minizinc/flatzingo/configuration/docker.msc /flatzingo/flatzingo.msc
# Make solver the default
RUN echo '{"tagDefaults": [["", "org.potassco.flatzingo"]]}' > $HOME/.minizinc/Preferences.json
# Add to MiniZinc search path
ENV MZN_SOLVER_PATH=/flatzingo:${MZN_SOLVER_PATH}