mirror of
https://github.com/jhbruhn/ics-adapter.git
synced 2025-03-15 03:25:49 +00:00
Make dockerfile crosscompile-ready
This commit is contained in:
parent
8f66bcdc8c
commit
fe84f86aa2
2 changed files with 29 additions and 4 deletions
14
Dockerfile
14
Dockerfile
|
@ -1,15 +1,21 @@
|
||||||
FROM rust:1.70 as builder
|
FROM --platform=$BUILDPLATFORM rust:1.70 as cross
|
||||||
|
ARG TARGETARCH
|
||||||
|
COPY docker/platform.sh .
|
||||||
|
RUN ./platform.sh # should write /.platform and /.compiler
|
||||||
|
RUN rustup target add $(cat /.platform)
|
||||||
|
RUN apt update && apt-get install -y unzip $(cat /.compiler)
|
||||||
|
|
||||||
RUN USER=root cargo new --bin ics-adapter
|
RUN USER=root cargo new --bin ics-adapter
|
||||||
WORKDIR ./ics-adapter
|
WORKDIR ./ics-adapter
|
||||||
COPY ./Cargo.toml ./Cargo.toml
|
COPY ./Cargo.toml ./Cargo.toml
|
||||||
RUN cargo build --release
|
RUN cargo build --release --target $(cat /.platform)
|
||||||
RUN rm src/*.rs
|
RUN rm src/*.rs
|
||||||
|
|
||||||
ADD . ./
|
ADD . ./
|
||||||
|
|
||||||
RUN rm ./target/release/deps/ics_adapter*
|
RUN rm ./target/release/deps/ics_adapter*
|
||||||
RUN cargo build --release
|
RUN cargo build --release --target $(cat /.platform)
|
||||||
|
RUN cp /usr/src/trow/target/$(cat /.platform)/release/ics-adapter /ics-adapter.bin # Get rid of this when build --out is stable
|
||||||
|
|
||||||
|
|
||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
|
@ -28,7 +34,7 @@ RUN groupadd $APP_USER \
|
||||||
&& useradd -g $APP_USER $APP_USER \
|
&& useradd -g $APP_USER $APP_USER \
|
||||||
&& mkdir -p ${APP}
|
&& mkdir -p ${APP}
|
||||||
|
|
||||||
COPY --from=builder /ics-adapter/target/release/ics-adapter ${APP}/ics-adapter
|
COPY --from=cross /ics-adapter.bin ${APP}/ics-adapter
|
||||||
|
|
||||||
RUN chown -R $APP_USER:$APP_USER ${APP}
|
RUN chown -R $APP_USER:$APP_USER ${APP}
|
||||||
|
|
||||||
|
|
19
docker/platform.sh
Executable file
19
docker/platform.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Used in Docker build to set platform dependent variables
|
||||||
|
|
||||||
|
case $TARGETARCH in
|
||||||
|
|
||||||
|
"amd64")
|
||||||
|
echo "x86_64-unknown-linux-gnu" > /.platform
|
||||||
|
echo "" > /.compiler
|
||||||
|
;;
|
||||||
|
"arm64")
|
||||||
|
echo "aarch64-unknown-linux-gnu" > /.platform
|
||||||
|
echo "gcc-aarch64-linux-gnu" > /.compiler
|
||||||
|
;;
|
||||||
|
"arm")
|
||||||
|
echo "armv7-unknown-linux-gnueabihf" > /.platform
|
||||||
|
echo "gcc-arm-linux-gnueabihf" > /.compiler
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in a new issue