|
|
|
@ -37,6 +37,7 @@ FROM --platform=linux/amd64 docker.io/tonistiigi/xx@sha256:c64defb9ed5a91eacb37f |
|
|
|
########################## BUILD IMAGE ########################## |
|
|
|
# hadolint ignore=DL3006 |
|
|
|
FROM --platform=$BUILDPLATFORM docker.io/library/rust:1.97.1-slim-trixie AS build |
|
|
|
# hadolint ignore=DL3067 |
|
|
|
COPY --from=xx / / |
|
|
|
ARG TARGETARCH |
|
|
|
ARG TARGETVARIANT |
|
|
|
@ -80,7 +81,7 @@ RUN mkdir -pv "${CARGO_HOME}" && \ |
|
|
|
RUN USER=root cargo new --bin /app |
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
RUN source /env-cargo && \ |
|
|
|
RUN . /env-cargo && \ |
|
|
|
rustup target add "${CARGO_TARGET}" |
|
|
|
|
|
|
|
# Copies over *only* your manifests and build files |
|
|
|
@ -95,7 +96,7 @@ ARG DB=sqlite,mysql,postgresql |
|
|
|
# Builds your dependencies and removes the |
|
|
|
# dummy project, except the target folder |
|
|
|
# This folder contains the compiled dependencies |
|
|
|
RUN source /env-cargo && \ |
|
|
|
RUN . /env-cargo && \ |
|
|
|
# Configure xx-cargo for target pkg-config and Debian transitive library lookup |
|
|
|
# https://github.com/tonistiigi/xx/pull/108#issuecomment-3700635977 |
|
|
|
# https://github.com/dani-garcia/vaultwarden/discussions/7522 |
|
|
|
@ -113,7 +114,7 @@ COPY . . |
|
|
|
ARG VW_VERSION |
|
|
|
|
|
|
|
# Builds again, this time it will be the actual source files being build |
|
|
|
RUN source /env-cargo && \ |
|
|
|
RUN . /env-cargo && \ |
|
|
|
# Make sure that we actually build the project by updating the src/main.rs timestamp |
|
|
|
# Also do this for build.rs to ensure the version is rechecked |
|
|
|
touch build.rs src/main.rs && \ |
|
|
|
@ -126,7 +127,7 @@ RUN source /env-cargo && \ |
|
|
|
export XX_RUSTFLAGS; \ |
|
|
|
fi && \ |
|
|
|
PKG_CONFIG="$(command -v "$(xx-info)-pkg-config")" xx-cargo build --features ${DB} --profile "${CARGO_PROFILE}" && \ |
|
|
|
if [[ "${CARGO_PROFILE}" == "dev" ]] ; then \ |
|
|
|
if [ "${CARGO_PROFILE}" = "dev" ] ; then \ |
|
|
|
ln -vfsr "/app/target/${CARGO_TARGET}/debug" /app/target/final ; \ |
|
|
|
else \ |
|
|
|
ln -vfsr "/app/target/${CARGO_TARGET}/${CARGO_PROFILE}" /app/target/final ; \ |
|
|
|
@ -149,6 +150,7 @@ RUN source /env-cargo && \ |
|
|
|
# To uninstall: docker run --privileged --rm tonistiigi/binfmt --uninstall 'qemu-*' |
|
|
|
# |
|
|
|
# We need to add `--platform` here, because of a podman bug: https://github.com/containers/buildah/issues/4742 |
|
|
|
# hadolint ignore=DL3065 |
|
|
|
FROM --platform=$TARGETPLATFORM docker.io/library/debian:trixie-slim |
|
|
|
|
|
|
|
ENV ROCKET_PROFILE="release" \ |
|
|
|
|