-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.fixed
71 lines (62 loc) · 1.96 KB
/
Dockerfile.fixed
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
# Specify the base image
FROM openqp/openqp:v1.0
USER root
# Install Python and required dependencies
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a Python wrapper script
RUN echo '#!/usr/bin/env python3\n\
import sys\n\
import subprocess\n\
import os\n\
\n\
def run_openqp():\n\
if len(sys.argv) != 2:\n\
print("Usage: openqp_wrapper <input_file>")\n\
sys.exit(1)\n\
\n\
input_file = sys.argv[1]\n\
if not os.path.exists(input_file):\n\
print(f"Error: Input file {input_file} not found")\n\
sys.exit(1)\n\
\n\
try:\n\
result = subprocess.run(\n\
["/usr/local/bin/openqp.bin", input_file],\n\
check=True,\n\
stdout=subprocess.PIPE,\n\
stderr=subprocess.PIPE,\n\
text=True\n\
)\n\
print(result.stdout)\n\
if result.stderr:\n\
print("Errors:", result.stderr, file=sys.stderr)\n\
except subprocess.CalledProcessError as e:\n\
print(f"Error running OpenQP: {e}", file=sys.stderr)\n\
print("Output:", e.output)\n\
print("Errors:", e.stderr, file=sys.stderr)\n\
sys.exit(e.returncode)\n\
except Exception as e:\n\
print(f"Unexpected error: {e}", file=sys.stderr)\n\
sys.exit(1)\n\
\n\
if __name__ == "__main__":\n\
run_openqp()' > /usr/local/bin/openqp_wrapper.py
# Move the original openqp binary
RUN mv /usr/local/bin/openqp /usr/local/bin/openqp.bin
# Create a new openqp command that uses the wrapper
RUN echo '#!/bin/bash\n\
python3 /usr/local/bin/openqp_wrapper.py "$@"' > /usr/local/bin/openqp
# Set proper permissions
RUN chmod +x /usr/local/bin/openqp.bin \
&& chmod +x /usr/local/bin/openqp \
&& chmod +x /usr/local/bin/openqp_wrapper.py
# Verify the installation
RUN ls -l /usr/local/bin/openqp* \
&& python3 --version
# Set the working directory
WORKDIR /data