You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+75-8Lines changed: 75 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# Rust Linux / Darwin Builder [](https://hub.docker.com/r/joseluisq/rust-linux-darwin-builder/)
1
+
# Rust Linux / Darwin Builder [](https://hub.docker.com/r/joseluisq/rust-linux-darwin-builder/)[](https://travis-ci.com/joseluisq/rust-linux-darwin-builder)[](https://hub.docker.com/r/joseluisq/rust-linux-darwin-builder/tags)[](https://hub.docker.com/r/joseluisq/rust-linux-darwin-builder/)
2
2
3
3
> Use same Docker image for compiling [Rust](https://www.rust-lang.org/) programs for Linux ([musl libc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html)) & macOS ([osxcross](https://github.com/tpoechtrager/osxcross)).
4
4
5
5
## Overview
6
6
7
-
This is a __Linux Docker image__that extends from [ekidd/rust-musl-builder](https://hub.docker.com/r/ekidd/rust-musl-builder)containing all necessary tools for compile [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image.
7
+
This is a __Linux Docker image__based on [ekidd/rust-musl-builder](https://hub.docker.com/r/ekidd/rust-musl-builder)but using [debian:buster-slim](https://hub.docker.com/_/debian?tab=tags&page=1&name=buster-slim). It contains essential tools for compile [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image.
8
8
9
9
## Usage
10
10
@@ -17,7 +17,7 @@ docker run --rm \
17
17
--user rust:rust \
18
18
--volume "${PWD}/sample":/home/rust/sample \
19
19
--workdir /home/rust/sample \
20
-
joseluisq/rust-linux-darwin-builder:1.40.0 \
20
+
joseluisq/rust-linux-darwin-builder:1.42.0 \
21
21
sh -c "cargo build --release"
22
22
```
23
23
@@ -28,18 +28,85 @@ docker run --rm \
28
28
--user rust:rust \
29
29
--volume "${PWD}/sample":/home/rust/sample \
30
30
--workdir /home/rust/sample \
31
-
joseluisq/rust-linux-darwin-builder:1.40.0 \
31
+
joseluisq/rust-linux-darwin-builder:1.42.0 \
32
32
sh -c "cargo build --release --target x86_64-apple-darwin"
33
33
```
34
34
35
-
*__Note:__ This example is also available under [./sample](./sample) directory.*
36
-
37
35
### Dockerfile
38
36
39
37
You can also use the image as a base for your own Dockerfile:
40
38
41
39
```Dockerfile
42
-
FROM joseluisq/rust-linux-darwin-builder:1.40.0
40
+
FROM joseluisq/rust-linux-darwin-builder:1.42.0
41
+
```
42
+
43
+
### Custom directories
44
+
45
+
By default this image uses a `rust` user and the default working directory is `/home/rust`.
46
+
If you want to use a different directory, change the corresponding owner and group as well.
47
+
48
+
```sh
49
+
sudo chown -R rust:rust /custom/directory
50
+
```
51
+
52
+
#### Cross-compilation example
53
+
54
+
Below a simple example using a `Makefile` for cross-compiling a Rust app.
55
+
56
+
Notes:
57
+
58
+
- A [hello world](./tests/hello-world) app is used.
59
+
- A custom directory is used below as working directory (instead of `/home/rust`).
60
+
- If you want to use the default `/home/rust` as working directory, owner and group change is not necessary.
0 commit comments