-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
104 lines (74 loc) · 2.79 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
FROM rust:alpine AS builder
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ARG COMPILET_FEATURES="c,cpp,rs"
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache musl-dev git
RUN mkdir /tmp/tempproj && \
cd /tmp/tempproj && \
cargo init && \
cargo add serde && \
rm -rf /tmp/tempproj
WORKDIR /app
COPY . .
RUN cargo build --release --no-default-features --features $COMPILET_FEATURES
FROM alpine AS runtime-rs
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ARG COMPILET_FEATURES="rs"
WORKDIR /app
# Install Rust toolchain
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache curl lld git && \
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \
source $HOME/.cargo/env && \
rustup target add wasm32-wasi
ENV PATH="/root/.cargo/bin:${PATH}"
# Update crates.io index
RUN mkdir /tmp/tempproj && \
cd /tmp/tempproj && \
cargo init && \
cargo add serde && \
cd / && \
rm -rf /tmp/tempproj
# Copy the binary from the build stage
COPY --from=builder /app/target/release/compilet /app/compilet
ENTRYPOINT ["/app/compilet"]
FROM alpine AS runtime-c
ARG COMPILET_FEATURES="c,cpp"
WORKDIR /app
# Install Rust toolchain
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache clang18 lld
# Copy WASI libs
COPY --from=ghcr.io/webassembly/wasi-sdk /opt/wasi-sdk/share/wasi-sysroot /app/stdlib/wasi-sysroot
COPY --from=ghcr.io/webassembly/wasi-sdk /opt/wasi-sdk/lib/clang/18/lib/wasi /usr/lib/llvm18/lib/clang/18/lib/wasi
# Copy the binary from the build stage
COPY --from=builder /app/target/release/compilet /app/compilet
ENTRYPOINT ["/app/compilet"]
FROM alpine AS runtime
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ARG COMPILET_FEATURES="c,cpp,rs"
WORKDIR /app
# Install Rust toolchain
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache curl clang18 lld git && \
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable && \
source $HOME/.cargo/env && \
rustup target add wasm32-wasi
ENV PATH="/root/.cargo/bin:${PATH}"
# Update crates.io index
RUN mkdir /tmp/tempproj && \
cd /tmp/tempproj && \
cargo init && \
cargo add serde && \
cd / && \
rm -rf /tmp/tempproj
# Copy WASI libs
COPY --from=ghcr.io/webassembly/wasi-sdk /opt/wasi-sdk/share/wasi-sysroot /app/stdlib/wasi-sysroot
COPY --from=ghcr.io/webassembly/wasi-sdk /opt/wasi-sdk/lib/clang/18/lib/wasi /usr/lib/llvm18/lib/clang/18/lib/wasi
# Copy the binary from the build stage
COPY --from=builder /app/target/release/compilet /app/compilet
ENTRYPOINT ["/app/compilet"]