This Dockerfile is designed to allow cross-compilation of Rust projects for Windows from a Linux or macOS host. It includes the Rust toolchain and a GNU C/C++ cross-compiler for Windows, as well as a shared volume for the source code.
And also this repo demonstrates how to locally compile lightweight Tauri applications to Windows executable (win64) using example Tauri application project tauri-app-builder and tauri-app-vanilla.
-
Clone the repository:
git clone --recursive https://github.com/afanasjev82/tauri-app-builder.git cd ./tauri-app-builder
-
Build the image:
docker build -t tauri-app-builder .
This will create a Docker image named
tauri-app-builder
that includes the necessary tools for cross-compiling Rust projects for Windows. -
Usage:
To use the
tauri-app-builder
image, you'll need to mount a volume containing your Rust project's source code. You can do this by running the following command:docker run --rm -v /path/to/tauri/project:/app tauri-app-builder
This command will run a container using the rust-cross-compile image and mount the
/path/to/tauri/project
directory as a volume inside the container. The src-tauri directory inside your project will be set as the working directory, and the cargo build command will be executed with the --release flag and the target set to x86_64-pc-windows-gnu. The resulting binary will be placed in the/path/to/tauri/project/build
directory, which is also mounted as a volume.
To compile example Tauri project tauri-app-vanilla
using tauri-app-builder
image, please do the following:
-
(optional) If repo was cloned without
--recursive
, initialize repo's submodulesgit submodule update --init
This will clone
tauri-app-vanilla
example Tauri application source into./tauri-app-vanilla
. If not successfull (I sometime encounter that issue) clone example repo manually by running following command in the root of this repository:git clone https://github.com/afanasjev82/tauri-app-vanilla.git
-
Build
tauri-app-vanilla
Windows executable using ourtauri-app-builder
:docker run --rm -v ./tauri-app-vanilla:/app tauri-app-builder
And then you compiled executable will wait you in the
./tauri-app-vanilla/build/x86_64-pc-windows-gnu/release/tauri-app-vanilla.exe
folder.