-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainerfile_zig
76 lines (57 loc) · 2.5 KB
/
Containerfile_zig
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
#*----------------------------------------------------------------------
#* pythonbuild
#*----------------------------------------------------------------------
FROM docker.io/library/python:3.12.3-alpine as pythonbuild
ARG ENABLE_TESTS
ARG PI_DIGITS_FILE=/app/src/pi_digits_seed.zig
WORKDIR /app
COPY . /app
RUN apk upgrade && \
ENABLE_TESTS=$ENABLE_TESTS PI_DIGITS_FILE=$PI_DIGITS_FILE ./etc/gen_run_pytests.sh
#*----------------------------------------------------------------------
#* zigbuild
#*----------------------------------------------------------------------
FROM docker.io/library/alpine as zigbuild
ARG ENABLE_TESTS
ARG PI_DIGITS_FILE=/app/src/pi_digits_seed.zig
WORKDIR /app
COPY ./etc /app/etc
COPY pi-zig /app
COPY --from=pythonbuild $PI_DIGITS_FILE $PI_DIGITS_FILE
# RUN ZIGVER=0.11.0 && ZIGARCH=zig-linux-x86_64-$ZIGVER.tar.xz && ZIGBIN=zig-bin && \
RUN ZIGVER=0.13.0 && ZIGARCH=zig-linux-x86_64-$ZIGVER.tar.xz && ZIGBIN=zig-bin && \
apk upgrade && \
apk add binaryen && \
wget -O $ZIGARCH https://ziglang.org/download/$ZIGVER/$ZIGARCH && \
tar xf $ZIGARCH && \
ENABLE_TESTS=$ENABLE_TESTS PI_DIGITS_FILE=$PI_DIGITS_FILE ZIGARCH=$ZIGARCH ZIGBIN=$ZIGBIN ./etc/build_run_zig_tests.sh && \
wasm-dis zig-out/bin/pi-zig.wasm -o zig-out/bin/pi-zig.wat
#*----------------------------------------------------------------------
#* build
#*----------------------------------------------------------------------
FROM docker.io/library/node:20-alpine as build
RUN apk upgrade
# ENV TZ=PST8PDT set in docker-compose.yml
WORKDIR /app
COPY . /app
COPY --from=zigbuild /app/zig-build.* .
COPY --from=zigbuild /app/zig-tests.* .
# used for integration testing pi-zig.wasm: execute `node public/pi-zig.cjs` in the container
COPY --from=zigbuild /app/zig-out/bin/pi-zig.cjs ./public/pi-zig.cjs
COPY --from=zigbuild /app/zig-out/bin/pi-zig.wasm ./public/pi-zig.wasm
COPY --from=zigbuild /app/zig-out/bin/pi-zig.wat ./public/pi-zig.wat
COPY --from=pythonbuild /app/piadapter.tgz ./public/piadapter.tgz
COPY --from=pythonbuild /app/python-tests.* .
RUN npm install && \
WASM_LANG=zig etc/clean_final.sh && \
rm -fr etc/
## Until I can work through the pyodide build issues ...
EXPOSE 3000
CMD ["npm", "start"]
# RUN npm install && npm run build
#*----------------------------------------------------------------------
#* final
#*----------------------------------------------------------------------
# FROM nginx:mainline-alpine
# RUN apk upgrade --no-cache
# COPY --from=build /app/dist /usr/share/nginx/html