Skip to content

Latest commit

 

History

History
77 lines (44 loc) · 2.19 KB

docker.md

File metadata and controls

77 lines (44 loc) · 2.19 KB

Cross Compile Rust-Programs using Docker

Prerequisites

  • Docker

Steps

I have created an Dockerfile in my main branch of Rust-for-Malware-Development. lets build our image

docker build . -t windows_compile 

⚠️ : This build takes upto 3 GB Space

Next run the container in the following project Directory !

Once you’ve created the image, then you can run the container by executing the following command:

docker run --rm -v ‘your-pwd’:/app rust_cross_compile/windows

The -rm option will remove the container when the command completes. The -v command allows you to persist data after a container has existed by linking your container storage with your local machine. Replace ‘your-pwd’ with the absolute path to your Rust directory

Example i have compiled EDRChecker and executed on my Virtual Machine.

image

image

Modifying Dockerfile

Here is the Default version of Rust Container

FROM rust:latest

RUN apt update ; apt upgrade -y 
RUN apt install -y g++-mingw-w64-x86-64

RUN rustup target add x86_64-pc-windows-gnu 
RUN rustup toolchain install stable-x86_64-pc-windows-gnu 

WORKDIR /app

CMD ["cargo", "build", "--target", "x86_64-pc-windows-gnu"]

For --release you can modify the Dockerfile as Follows

FROM rust:latest

RUN apt update ; apt upgrade -y 
RUN apt install -y g++-mingw-w64-x86-64

RUN rustup target add x86_64-pc-windows-gnu 
RUN rustup toolchain install stable-x86_64-pc-windows-gnu 

WORKDIR /app

CMD ["cargo", "build", "--target", "x86_64-pc-windows-gnu", "--release"]

Here is the Image:

image

image

THE PATH WHERE IT COMPILES AND KEEPS BINARY FILES:

image