0

I get this error when building a Dockerfile with Buildx on my Mac Mini. The amd64 and arm64 images are built without a problem.

The Dockerfile looks like this:


    # syntax = docker/dockerfile:experimental
    
    FROM library/node:lts-bullseye as ui-builder
    
    WORKDIR /app
    COPY ./ui/ ./
    RUN  npm install && npm run build
    
    
    FROM rust:latest as dependency-cache
    
    
    USER root
    
    WORKDIR /app/src
    ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
    
    RUN rustc --version
    
    ADD Cargo.toml .
    ADD dummy.rs ./src/main.rs
    ADD build.rs .
    RUN cargo update
    RUN RUSTFLAGS='-C target-feature=-crt-static' cargo build --release
    
    
    FROM rust:latest as builder
    
    USER root
    
    WORKDIR /app/src
    
    
    ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
    
    
    COPY --from=dependency-cache /usr/local/cargo /usr/local/cargo
    COPY --from=dependency-cache /app/src/target/ /app/src/target/
    RUN rm -rf /app/src/static/*||true
    COPY --from=ui-builder /app/dist /app/src/static
    RUN rm -rf /app/src/target/release/deps/podfetch*
    RUN rm -rf /app/src/target/release/podfetch*
    
    ADD Cargo.toml .
    ADD static ./static
    ADD migrations ./migrations
    ADD src ./src
    ADD build.rs .
    ADD db ./db
    RUN cargo update
    RUN --security=insecure mkdir -p /usr/local/cargo/registry/index && \
        chmod 777 /usr/local/cargo/registry/index && \
        mount -t tmpfs none /usr/local/cargo/registry/index && \
        RUSTFLAGS='-C target-feature=-crt-static' cargo build --release
    
    
    FROM library/alpine:3.17 AS Runtime
    WORKDIR /app/
    RUN apk add libgcc tzdata
    ENV TZ=Europe/Berlin
    
    COPY --from=builder /app/src/target/release/podfetch /app/podfetch
    COPY --from=builder /app/src/migrations /app/migrations
    COPY --from=builder /app/src/db /app/db
    COPY --from=ui-builder /app/dist /app/static
    COPY ./docs/default.jpg /app/static/default.jpg
    
    
    EXPOSE 8000
    CMD ["./podfetch"]

If you want to reproduce the issue:

  1. git clone https://github.com/SamTV12345/PodFetch.git
  2. git checkout origin 109-readd-armv7-support
  3. docker buildx build --allow security.insecure --platform linux/arm/v7 --pull --push -f Dockerfile_armv7 -m 4g -t samuel19982/podfetch:devarmv7 .

The full error log is this:


     > [dependency-cache 7/8] RUN cargo update:
    #24 0.470     Updating crates.io index
    #24 46.84 From https://github.com/rust-lang/crates.io-index
    #24 46.84  * [new ref]                          -> origin/HEAD
    #24 46.92 error: no matching package named `actix` found
    #24 46.92 location searched: registry `crates-io`
    #24 46.92 required by package `podfetch v0.1.0 (/app/src)`

SamTV
  • 147
  • 1
  • 11
  • 1
    I'm not sure why `cargo update` isn't working, but using it during a docker build is a little bit weird anyway… Why not go for something more classic like [this](https://stackoverflow.com/a/64528456/401059)? (If anything, at least don't run `cargo update` twice. You might end up with two different `Cargo.lock` files…) – Caesar May 07 '23 at 22:38
  • But this still doesn't allow me to build ARMv7 on an arm64 cpu doesn't it? – SamTV May 09 '23 at 19:25
  • Hmm. Since you were using `--platform linux/arm/v7` (and no `FROM --platform=$BUILDPLATFORM` in sight), I assumed you're also using `qemu-user-static`. So, you should be able to build ARMv7 on anything, including x86. – Caesar May 09 '23 at 23:06
  • I have the problem that the builder images seem to require armv7. If I don't have an armv7 Rust builder image it does not work. – SamTV May 10 '23 at 15:00
  • alpine, rust, and node all have armv7 variants for the tags your use. So that shouldn't be a problem either… – Caesar May 10 '23 at 22:35
  • I can't find one for Rust that supports musl. – SamTV May 11 '23 at 04:40
  • `FROM rust` `RUN rustup target add armv7-unknown-linux-musleabi`? Though let me tell you: You'll have a bad time if you have any C libraries among your dependencies. [musl-cross](https://musl.cc/) exists but it's a PITA to work with in docker. – Caesar May 12 '23 at 04:40
  • I chose cross. Unfortunately that doesn’t have musl support. So only Linux GNU works for building. – SamTV May 12 '23 at 10:04

0 Answers0