-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (49 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
60 lines (49 loc) · 1.79 KB
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
# syntax=docker/dockerfile:1.7-labs
FROM rust:bookworm AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
pkg-config \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN cargo install cargo-component --locked && cargo install wasm-tools --locked
WORKDIR /usr/src/app
COPY Cargo.toml ./
COPY wit ./wit
RUN mkdir -p src && printf 'pub fn placeholder() {}\n' > src/lib.rs
# warm dependency cache only
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
cargo component build --release || true
COPY . .
RUN set -eux; \
pwd; \
ls -la; \
echo "---- src ----"; \
ls -la src; \
echo "---- wit ----"; \
ls -la wit; \
echo "---- Cargo.toml ----"; \
sed -n '1,200p' Cargo.toml; \
echo "---- src/lib.rs ----"; \
sed -n '1,200p' src/lib.rs; \
echo "---- src/bindings.rs ----"; \
sed -n '1,120p' src/bindings.rs; \
echo "---- wit/world.wit ----"; \
sed -n '1,200p' wit/world.wit
# force real rebuild from real sources
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
set -eux; \
rm -rf /usr/src/app/target; \
cargo component build --release; \
echo "---- release dir ----"; \
ls -l /usr/src/app/target/wasm32-wasip1/release; \
echo "---- component wit ----"; \
wasm-tools component wit /usr/src/app/target/wasm32-wasip1/release/aa_proxy_test_hook.wasm; \
mkdir -p /out; \
cp /usr/src/app/target/wasm32-wasip1/release/aa_proxy_test_hook.wasm /out/test_hook.wasm
FROM scratch AS export
COPY --from=builder /out/ /
# DOCKER_BUILDKIT=1 docker build --target export --output type=local,dest=./output .
# scp -O output/*.wasm root@10.0.0.1:/data/wasm-hooks/