Skip to content

Commit 0c6f532

Browse files
committed
fix: update containerised Dockerfile
1 parent d01e0a8 commit 0c6f532

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

containerised/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Builder ##
33
#############
44

5-
FROM --platform=linux/amd64 rust:slim AS builder
5+
FROM --platform=$BUILDPLATFORM rust:slim AS builder
66

77
ARG TARGETARCH
88

@@ -11,9 +11,9 @@ ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="aarch64-linux-gnu-gcc"
1111
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-lgcc"
1212
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER="arm-linux-gnueabihf-ld"
1313

14-
COPY ./containerised/platform.sh .
14+
COPY ./containerised/target.sh .
1515

16-
RUN chmod +x ./platform.sh && ./platform.sh
16+
RUN chmod +x ./target.sh && ./target.sh
1717

1818
RUN apt-get update && apt-get install $(cat /.compiler) -y
1919

@@ -29,10 +29,10 @@ COPY Cargo.* /usr/src/oxker/
2929
WORKDIR /usr/src/oxker
3030

3131
# Install target platform (Cross-Compilation)
32-
RUN rustup target add $(cat /.platform)
32+
RUN rustup target add $(cat /.target)
3333

3434
# This is a dummy build to get the dependencies cached - probably not needed - as run via a github action
35-
RUN cargo build --target $(cat /.platform) --release
35+
RUN cargo build --target $(cat /.target) --release
3636

3737
# Now copy in the rest of the sources
3838
COPY src /usr/src/oxker/src/
@@ -41,9 +41,9 @@ COPY src /usr/src/oxker/src/
4141
RUN touch /usr/src/oxker/src/main.rs
4242

4343
# This is the actual application build
44-
RUN cargo build --release --target $(cat /.platform)
44+
RUN cargo build --release --target $(cat /.target)
4545

46-
RUN cp /usr/src/oxker/target/$(cat /.platform)/release/oxker /
46+
RUN cp /usr/src/oxker/target/$(cat /.target)/release/oxker /
4747

4848
#############
4949
## Runtime ##

containerised/target.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
# Used in Docker build to set platform dependent variables
3+
4+
case $TARGETARCH in
5+
6+
"amd64")
7+
echo "x86_64-unknown-linux-musl" >/.target
8+
echo "" >/.compiler
9+
;;
10+
"arm64")
11+
echo "aarch64-unknown-linux-musl" >/.target
12+
echo "gcc-aarch64-linux-gnu" >/.compiler
13+
;;
14+
"arm")
15+
echo "arm-unknown-linux-musleabihf" >/.target
16+
echo "gcc-arm-linux-gnueabihf" >/.compiler
17+
;;
18+
esac

0 commit comments

Comments
 (0)