-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathDockerfile.local
More file actions
73 lines (62 loc) · 2.43 KB
/
Dockerfile.local
File metadata and controls
73 lines (62 loc) · 2.43 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
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM ubuntu:22.04
# Toolchain versions — bump these together when upgrading.
ARG VERSION_RUST="1.93.0"
ARG VERSION_SC_META="local"
ARG VERSION_WASM_OPT="0.116.1"
ARG TARGETPLATFORM
# Install system dependencies
RUN apt-get update --fix-missing && apt-get install -y \
wget \
build-essential \
git \
pkg-config \
libssl-dev
# Install Rust
RUN wget -O rustup.sh https://sh.rustup.rs && \
chmod +x rustup.sh && \
CARGO_HOME=/rust RUSTUP_HOME=/rust ./rustup.sh \
--verbose \
--default-toolchain ${VERSION_RUST} \
--profile minimal \
-y && \
rm rustup.sh && \
chmod -R 777 /rust && \
rm -rf /rust/registry
# Install sc-meta from the local source tree.
# Build context must be the workspace root:
# docker build -f framework/meta/Dockerfile.local <workspace-root>
COPY . /mx-sdk-rs
RUN PATH="/rust/bin:${PATH}" CARGO_HOME=/rust RUSTUP_HOME=/rust \
cargo install --path /mx-sdk-rs/framework/meta --locked && \
rm -rf /rust/registry && \
rm -rf /mx-sdk-rs
# Install wasm32 target
RUN PATH="/rust/bin:${PATH}" CARGO_HOME=/rust RUSTUP_HOME=/rust \
sc-meta install wasm32
# Install wasm-opt
RUN PATH="/rust/bin:${PATH}" CARGO_HOME=/rust RUSTUP_HOME=/rust \
cargo install wasm-opt --version ${VERSION_WASM_OPT} --locked && \
rm -rf /rust/registry
ENV PATH="/rust/bin:${PATH}"
ENV CARGO_HOME="/rust"
ENV RUSTUP_HOME="/rust"
# Exposed to sc-meta at runtime for embedding into .source.json build metadata.
ENV BUILD_METADATA_VERSION_RUST=${VERSION_RUST}
ENV BUILD_METADATA_VERSION_SC_META=${VERSION_SC_META}
ENV BUILD_METADATA_VERSION_WASM_OPT=${VERSION_WASM_OPT}
ENV BUILD_METADATA_TARGETPLATFORM=${TARGETPLATFORM}
# /project — mounted read-only by the caller (the contract source tree)
# /output — mounted read-write by the caller (build artifacts land here)
# /rust/cargo-target-dir — optionally mounted for caching between runs
# Additional arguments forwarded at "docker run" time:
# --project /project (required; set automatically by docker-build)
# --contract <name> (optional)
# --no-wasm-opt (optional)
# --build-root <path> (optional; defaults to /tmp/sc-build inside the container)
ENTRYPOINT ["sc-meta", "reproducible-build", "local-build", \
"--output", "/output", \
"--target-dir", "/rust/cargo-target-dir"]
LABEL frozen="no"
LABEL rust=${VERSION_RUST}
LABEL sc_meta=${VERSION_SC_META}
LABEL wasm_opt=${VERSION_WASM_OPT}