Skip to content

Commit

Permalink
add ability to cross compile using docker
Browse files Browse the repository at this point in the history
  • Loading branch information
atomicptr committed Dec 27, 2024
1 parent 93a5b66 commit ef54ccd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/build

# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,rust
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,rust

Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo rm -rf ./build
docker build -t doryani-build -f cc.Dockerfile .
docker run -v ./build:/build doryani-build

echo "Finished building!"

ls -al build
24 changes: 24 additions & 0 deletions cc.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM rust:latest

WORKDIR /app

COPY . /app

RUN apt update && \
apt upgrade -y && \
apt install -y g++ g++-mingw-w64-x86-64 zip && \
rustup target add x86_64-unknown-linux-gnu && \
rustup target add x86_64-pc-windows-gnu && \
rustup toolchain install stable-x86_64-unknown-linux-gnu && \
rustup toolchain install stable-x86_64-pc-windows-gnu

RUN cargo build --release --target x86_64-unknown-linux-gnu && \
cargo build --release --target x86_64-pc-windows-gnu && \
mkdir /app/builds && \
tar -czvf /app/builds/doryani-linux-x86_64.tar.gz /app/target/x86_64-unknown-linux-gnu/release/doryani && \
zip -r /app/builds/doryani-windows-x86_64.zip /app/target/x86_64-pc-windows-gnu/release/doryani.exe && \
ls -al /app/builds

WORKDIR /build

CMD ["/bin/sh", "-c", "mv /app/builds/doryani-linux-x86_64.tar.gz /build/; mv /app/builds/doryani-windows-x86_64.zip /build/"]

0 comments on commit ef54ccd

Please sign in to comment.