From 43adcde0946da746aaf99f31012a5c00c517b850 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:38:55 +0100 Subject: [PATCH] Move `rustup target` before `cargo build`. Thanks to @dani-garcia! Note from @dani-garcia: > I don't think this is doing anything right now because the target is probably > installed already. --- docker/Dockerfile.j2 | 12 +++++++----- docker/aarch64/mysql/Dockerfile | 3 ++- docker/aarch64/sqlite/Dockerfile | 3 ++- docker/amd64/mysql/Dockerfile.alpine | 4 ++-- docker/amd64/postgresql/Dockerfile.alpine | 4 ++-- docker/amd64/sqlite/Dockerfile.alpine | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index c273b4ed..d2d942d9 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -176,6 +176,13 @@ ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" {% endif -%} +{% if "alpine" in target_file %} +RUN rustup target add x86_64-unknown-linux-musl + +{% elif "aarch64" in target_file %} +RUN rustup target add aarch64-unknown-linux-gnu + +{% endif %} # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -189,16 +196,11 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -{% if "alpine" in target_file %} -RUN rustup target add x86_64-unknown-linux-musl - -{% endif %} # Builds again, this time it'll just be # your actual source files being built {% if "amd64" in target_file %} RUN cargo build --features ${DB} --release {% elif "aarch64" in target_file %} -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu {% endif %} diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e15c25b5..4faea593 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -77,6 +77,8 @@ ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +RUN rustup target add aarch64-unknown-linux-gnu + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -92,7 +94,6 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu ######################## RUNTIME IMAGE ######################## diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 1cebf6b3..5eb00a3f 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -71,6 +71,8 @@ ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +RUN rustup target add aarch64-unknown-linux-gnu + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -86,7 +88,6 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu ######################## RUNTIME IMAGE ######################## diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 62ad91d7..56151652 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -47,6 +47,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -60,8 +62,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index a2429058..903a1a30 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -47,6 +47,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -60,8 +62,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 831eae52..221e7e9e 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -41,6 +41,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -54,8 +56,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release