-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
125 lines (99 loc) · 3.88 KB
/
Dockerfile
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From python:3.10.2 AS base
ENV EMSCRIPTEN_VERSION=3.1.14
RUN git clone --depth 1 https://github.com/emscripten-core/emsdk.git /emsdk && \
cd /emsdk && \
git pull && \
./emsdk install ${EMSCRIPTEN_VERSION} && \
./emsdk activate ${EMSCRIPTEN_VERSION} && \
rm -rf /emsdk/.git
SHELL ["/bin/bash", "-c"]
FROM base AS build-base
COPY Makefile /exodide/
COPY numpy /exodide/numpy/
COPY cpython /exodide/cpython/
COPY pyodide /exodide/pyodide/
COPY script /exodide/script/
WORKDIR /exodide
RUN source /emsdk/emsdk_env.sh && \
make && rm -rf numpy cpython pyodide script && rm -f Makefile
FROM build-base AS build-pre
COPY exodide /exodide/exodide/
COPY setup.py LICENSE /exodide/
FROM build-pre AS build
COPY README.md /exodide/
RUN python3 setup.py bdist_wheel -d /dist && rm -rf /exodide
FROM build-pre AS build-no-readme
RUN python3 setup.py bdist_wheel -d /dist && rm -rf /exodide
FROM base AS exodide
COPY --from=build /dist /dist/
RUN pip3 install /dist/* wheel && rm -rf /dist
WORKDIR /src
CMD ["bash"]
FROM base AS exodide-no-readme
COPY --from=build /dist /dist/
RUN pip3 install /dist/* wheel && rm -rf /dist
FROM exodide-no-readme AS example-build
COPY example/setup.py /example/
COPY example/pybind11 /example/pybind11/
COPY example/exodide_example /example/exodide_example/
WORKDIR /example
RUN source /emsdk/emsdk_env.sh && \
CC=emcc CXX=em++ python3 setup.py bdist_wheel -d /dist && rm -rf /example
FROM exodide-no-readme AS example-cmdless-build
COPY example/setup-cmdless.py /example/
COPY example/pybind11 /example/pybind11/
COPY example/exodide_example /example/exodide_example/
WORKDIR /example
RUN source /emsdk/emsdk_env.sh && \
CC=emcc CXX=em++ python3 setup-cmdless.py --command-packages exodide \
exodide_wheel -d /dist && \
rm -rf /example
FROM exodide-no-readme AS test
COPY test .coveragerc /test/
COPY --from=example-build /dist /example/
WORKDIR /test
RUN source /emsdk/emsdk_env.sh && \
unzip /example/*.whl -d /example && \
pip3 install coverage unittest-xml-reporting numpy && \
coverage run -m xmlrunner discover . && \
coverage report && \
mkdir -p /coverage/html && coverage html -d /coverage/html && \
mkdir -p /coverage/xml && cp *.xml /coverage/xml/ && \
rm -rf /test
FROM node:latest AS pyodide-node
WORKDIR /pyodide-node
RUN npm i pyodide@0.21.0 && \
npm i -g http-server && \
curl -LO https://github.com/pyodide/pyodide/releases/download/0.21.0/pyodide-build-0.21.0.tar.bz2 && \
tar xvf pyodide-build-0.21.0.tar.bz2 && \
rm -f pyodide-build-0.21.0.tar.bz2
FROM pyodide-node AS example-test
ENV DIST=/pyodide-node/dist/ TEST=example/test
COPY --from=build /dist $DIST
COPY --from=example-build /dist $DIST
COPY ${TEST}/test.mjs ${TEST}/test_example.py ${TEST}/run.sh /pyodide-node/example/
RUN sed -i \
-e s/"<exodide>"/$(find $DIST -name "exodide-*.whl" -exec basename {} \;)/ \
-e s/"<example>"/$(find $DIST -name "*_example-*.whl" -exec basename {} \;)/\
example/test_example.py && \
bash ./example/run.sh /pyodide-node && \
touch /example-test
FROM pyodide-node AS example-cmdless-test
ENV DIST=/pyodide-node/dist/ TEST=example/test
COPY --from=build /dist $DIST
COPY --from=example-cmdless-build /dist $DIST
COPY ${TEST}/test.mjs ${TEST}/test_example.py ${TEST}/run.sh /pyodide-node/example/
COPY --from=example-test /example-test /example-test
RUN sed -i \
-e s/"<exodide>"/$(find $DIST -name "exodide-*.whl" -exec basename {} \;)/ \
-e s/"<example>"/$(find $DIST -name "*_example-*.whl" -exec basename {} \;)/\
example/test_example.py && \
bash ./example/run.sh /pyodide-node && \
touch /example-cmdless-test
FROM scratch AS result
COPY --from=build /dist /dist/
COPY --from=example-build /dist /dist/
COPY --from=test /coverage /coverage/
COPY --from=example-test /example-test /example-test
COPY --from=example-cmdless-test /example-cmdless-test /example-cmdless-test
CMD [""]