Created
February 2, 2021 13:58
-
-
Save aeldar/b357662a3b7e42e95497a5db737b3d82 to your computer and use it in GitHub Desktop.
Build rust app for windows inside docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reduce the size of the executable file: | |
[profile.release] | |
lto = true | |
codegen-units = 1 | |
opt-level = "z" | |
panic = 'abort' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place this Dockerfile into a `windows-builder` empty directory next to the `build-for-windows.sh` file | |
FROM rust:1 | |
RUN rustup target add x86_64-pc-windows-gnu | |
RUN apt-get update \ | |
&& apt-get install -y mingw-w64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
SCRIPT_PATH=`readlink -f "$0"` | |
SCRIPT_DIR=`dirname "$SCRIPT_PATH"` | |
docker run \ | |
--rm \ | |
-it \ | |
--user "$(id -u)":"$(id -g)" \ | |
-v "$PWD":/usr/src/myapp \ | |
-w /usr/src/myapp $(docker build -q $SCRIPT_DIR/windows-builder) \ | |
cargo build --release --target x86_64-pc-windows-gnu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment