-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile_cli
53 lines (41 loc) · 1.4 KB
/
dockerfile_cli
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
# Use the official Rust image as the base
FROM rust:1.84.1-bullseye
# Install necessary dependencies
RUN apt-get update && apt-get install -y \
musl-tools \
curl \
unzip \
git \
wget \
zip \
&& rm -rf /var/lib/apt/lists/*
# Install Rust targets
RUN rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl \
x86_64-pc-windows-gnu aarch64-pc-windows-msvc \
x86_64-apple-darwin aarch64-apple-darwin
# Install Zig (required for cargo-zigbuild)
ENV ZIG_VERSION="0.13.0"
RUN wget https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar.xz \
&& tar -xf zig-linux-x86_64-${ZIG_VERSION}.tar.xz \
&& mv zig-linux-x86_64-${ZIG_VERSION} /opt/zig \
&& ln -s /opt/zig/zig /usr/local/bin/zig
# Verify Zig installation
RUN zig version
# Ensure Zig is available in PATH
ENV PATH="/opt/zig:$PATH"
# Install cargo-zigbuild
RUN cargo install cargo-zigbuild
# Set up working directory
WORKDIR /build
# Copy the project files
COPY . .
WORKDIR /build/cli
# Ensure dependencies are downloaded
RUN cargo fetch
# Build for multiple targets
RUN cargo zigbuild --release --target x86_64-unknown-linux-musl
RUN cargo zigbuild --release --target aarch64-unknown-linux-musl
RUN cargo zigbuild --release --target x86_64-pc-windows-gnu
RUN cargo zigbuild --release --target x86_64-apple-darwin
RUN cargo zigbuild --release --target aarch64-apple-darwin
CMD ["ls", "-lh"]