No matching package found (Docker + Rust) - docker

I'm attempting to compile a Rust project in Docker and it's being frustrating. As far as I can tell it should be incredibly straightforward, but for some reason Docker can't find the Rust package.
Here's the Dockerfile:
FROM rust:1.6.1
COPY . .
RUN cargo build --release
CMD ["./run.sh"]
Here's the Cargo.toml:
[package]
name = "project1_1"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
utility = { path = "./src/utility" }
iced = "0.6.0"
iced_native = "0.4"
iced_style = "0.5"
iced_core = "0.5"
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
webassembly = "0.8"
wry = "0.23.4"
And here's the output:
peterweyand#Peters-MacBook-Pro project1_1 % ./dockerrun.sh
2022/12/15 16:04:06 must use ASL logging (which requires CGO) if running as root
Sending build context to Docker daemon 1.351GB
Step 1/4 : FROM rust:1.6.1
manifest for rust:1.6.1 not found: manifest unknown: manifest unknown
Updating git repository `https://github.com/iced-rs/iced`
Updating crates.io index
error: no matching package found
searched package name: `iced`
perhaps you meant: cached
location searched: https://github.com/iced-rs/iced
required by package `project1_1 v0.1.0 (/)`
If instead of FROM rust:1.6.1 I use FROM rust:latest then Docker hangs like this:
peterweyand#Peters-MacBook-Pro project1_1 % ./dockerrun.sh
2022/12/15 16:08:18 must use ASL logging (which requires CGO) if running as root
Sending build context to Docker daemon 1.351GB
Step 1/4 : FROM rust:latest
---> 7767cd0ef4e0
Step 2/4 : COPY . .
---> 356cfb7caed9
Step 3/4 : RUN cargo build --release
---> Running in 87dbc6c86df9
Updating crates.io index
Does anyone have any ideas of what is going wrong?
EDIT: I usually suck at Docker because there are several ways of doing the same thing.
I tried this
FROM rust:1.66-alpine
WORKDIR /
COPY . .
RUN cargo install --path .
RUN apk add alpine-sdk # This one is necessary for linking cc.
COPY ./src/backend/Cargo.toml ./src/backend/Cargo.lock ./
RUN cargo build --release
CMD ["./run.sh"]
and it gave this output -
Compiling libloading v0.7.4
Compiling lock_api v0.4.9
Compiling parking_lot_core v0.9.5
Compiling toml v0.5.10
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling parking_lot v0.12.1
Compiling anyhow v1.0.66
Compiling system-deps v6.0.3
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-Wl,--version-script=/tmp/rustc2quFlR/list" "/tmp/rustc2quFlR/symbols.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.0.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.1.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.10.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.11.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.12.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.13.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.14.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.15.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.2.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.3.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.4.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.5.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.6.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.7.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.8.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.proc_macro_error_attr.1df7e329-cgu.9.rcgu.o" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.2venke7z0qwetnto.rcgu.rmeta" "/target/release/deps/proc_macro_error_attr-4660f50c1ee088e6.2bt08o7nuxqqfzig.rcgu.o" "-Wl,--as-needed" "-L" "/target/release/deps" "-L" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/target/release/deps/libquote-a78ece94a3329b46.rlib" "/target/release/deps/libproc_macro2-3f4d87b0b9f5c5f5.rlib" "/target/release/deps/libunicode_ident-5c658c6e9005d30d.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libproc_macro-16667debc3013ce2.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libstd-19bcd24d54b4a32c.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libpanic_unwind-3814851f75d61802.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libobject-5007cbad366e7f54.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libmemchr-c7fe0e6a7e22626a.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libaddr2line-cdbb9a3725d71a8c.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libgimli-ad66f8ef705486ae.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_demangle-775cf8425902e89f.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libstd_detect-d09dc442a73afb02.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcfg_if-508c53ad79acc8ea.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libhashbrown-ac7c150ef5940f2b.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libminiz_oxide-d2c5dbbafb505b02.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libadler-fa394ecd0326b64a.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_std_workspace_alloc-d36cf05357e3b9d8.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libunwind-32953872cd386e07.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcfg_if-e844973f6e14767e.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/liblibc-2f732132bffc407e.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/liballoc-e0c40e7f51c7608f.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_std_workspace_core-3dc8593378fc4be9.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcore-d31b035ed558dec3.rlib" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-2b952fa9bf703518.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/usr/local/rustup/toolchains/1.66.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib" "-o" "/target/release/deps/libproc_macro_error_attr-4660f50c1ee088e6.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
= note: /usr/lib/gcc/aarch64-alpine-linux-musl/12.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
error: could not compile `proc-macro-error-attr` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `project1_1 v0.1.0 (/)`, intermediate artifacts can be found at `/target`
The command '/bin/sh -c cargo install --path .' returned a non-zero code: 101
Unable to find image 'my-rust-app:latest' locally
2022/12/15 17:31:02 must use ASL logging (which requires CGO) if running as root
docker: Error response from daemon: pull access denied for my-rust-app, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
And I also tried this -
FROM ubuntu:latest
WORKDIR /
COPY . .
RUN apt-get update
RUN apt-get install protobuf-compiler openssl pkg-config libssl-dev rustc cmake cargo -y
RUN rustc -V
CMD ["./run.sh"]
But still ran into problems compiling dependencies that relied on C.
So, my question at this point is "What is the easiest way of getting a rust program to run with a standard list of dependencies?" The hello world examples don't cut it for any Rust program that has a large crate stack.
Thanks.

Related

Grafana don't build docker image

i have a problem to build the docker image for grafana.
i'm trying to build the image with make build-docker-full-ubuntu but when
go is building there is an error and the procedure exit with an error:
go: downloading github.com/pmezard/go-difflib v1.0.0
generate go files
/go/bin/wire-v0.5.0 gen -tags "oss" ./pkg/server ./pkg/cmd/grafana-cli/runner
wire: github.com/grafana/grafana/pkg/server: wrote /src/grafana/pkg/server/wire_gen.go
wire: github.com/grafana/grafana/pkg/cmd/grafana-cli/runner: wrote /src/grafana/pkg/cmd/grafana-cli/runner/wire_gen.go
build go files
go run build.go build
Version: 9.0.7, Linux Version: 9.0.7, Package Iteration: 1660317595
building binaries build
building grafana-server ./pkg/cmd/grafana-server
rm -r ./bin/linux-amd64/grafana-server
rm -r ./bin/linux-amd64/grafana-server.md5
go build -ldflags -w -X main.version=9.0.7 -X main.commit=unknown-dev -X main.buildstamp=1660317595 -X main.buildBranch=main -o ./bin/linux-amd64/grafana-server ./pkg/cmd/grafana-server
embed.go:9:20: pattern cue: no matching files found
exit status 1
exit status 1
make: *** [Makefile:92: build-go] Error 1
The command '/bin/sh -c make build-go' returned a non-zero code: 2
make: *** [Makefile:157: build-docker-full-ubuntu] Errore 2
outer the build go is builded correctly but in the image builder fail.
Anyone can help me?
i'm using ubuntu 20.04 e the grafana version is 9.0.7
Thanks in advice
this is delayed but this might help someone. just elaborating on the resolved comment.
Need to copy the cue folder from the source to the docker
add this line in DockerFile
- COPY cue cue

Private Azure PYPI not reachable in azure pipelines run

I have a project A managed with pipenv that depends on another project B built with pipenv too. The project B is published in the private PYPI. My Pipfile looks like
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://${USERNAME}:${TOKEN}#MyPrivateRepoUrl"
verify_ssl = true
name = "MyRepoPYPI"
When I install A locally I have not problems and every works fine (declaring environment variables with export command). I have configured an azure-pipelines.yml with 2 jobs, first install A and testing, and the second one is to build and publish the docker image to the ACR. When I trigger the pipeline, the first job fails with this error:
FAIL
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 741, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 709, in resolve_packages
[ResolutionFailure]: requirements_dir=requirements_dir,
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 692, in resolve
[ResolutionFailure]: req_dir=requirements_dir
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 1403, in resolve_deps
[ResolutionFailure]: req_dir=req_dir,
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 1108, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 833, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Could not find a version that matches pymooslotting (from -r /tmp/pipenvzsh1c47crequirements/pipenv-y37q7d_w-constraints.txt (line 11))
No versions found
Were https://pypi.org/simple or https://MyUsername:***#MyPrivateRepoUrl reachable?
I'm pretty sure the credentials are set correctly.
The amazing thing is that if I run the second job, the docker image is built correctly, therefore it is telling me that the credentials to install B are being passed correctly.
here is the part of the pipelines where I install A
steps:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.7'
architecture: 'x64'
- script: |
python -m pip install --user --upgrade pip
python -m pip install --user pipenv
displayName: Install Pipenv
- script: |
pipenv lock --clear
pipenv install --system
displayName: Install Dev Dependencies
- bash: pytest -rf
displayName: Unit test
I'm not commiting the lock file, but I have done many tests that include the lock in the repo.
Here is the command for docker Publish (that works fine and do the job)
- task: Docker#2
displayName: Build Docker Image
inputs:
command: build
containerRegistry: $(acrRepository)
repository: samples/execslotting
inputs:
tags: |
latest
$(tag)
arguments: '--build-arg USERNAME=$(MyUserName) --build-arg TOKEN=$(MyToken)'
The docker image is installing B, so in the build I pass USERNAME and TOKEN vars.
OBS: The error message No versions found Were https://pypi.org/simple or https://MyUsername:***#MyPrivateRepoUrl reachable? tells me that the envars are correctly read in the execution of the installation job.
the docs specify a different push and pull endpoint urls for pip... Try appending /pypi/simple to the repo description where you are pulling from.
full url: https://<your-feed-name>:<your-PAT-key>#pkgs.dev.azure.com/<your-organization-name>/<your-project-name>/_packaging/<your-feed-name>/pypi/simple/

How to solve this build error on Linux when building libsodium

I'm trying to build libsodium-sys dependency in an Azure Docker VM which is based on debian.
Have spend a couple of hours trying to fix this build error, but can't figure out what's going on.
I fixed a couple of build errors by installing missing dependencies as the Azure Docker VM seems very vanilla. Executed commands are below the error.
error: failed to run custom build command for `libsodium-sys v0.2.6 (https://github.com/cjdelisle/sodiumoxide?rev=76dc0e6e587b8c8a4bb193ebba9f8ae8f090b81b#76dc0e6e)`
Caused by:
process didn't exit successfully: `/home/packetcrypt_rs/target/release/build/libsodium-sys-169018138a0de36b/build-script-build` (exit code: 101)
checking for working alloca.h... yes
checking for alloca... yes
...
Making check in builds
--- stderr
/bin/bash: line 20: cd: builds: No such file or directory
make: *** [Makefile:516: check-recursive] Error 1
thread 'main' panicked at '
Failed to build libsodium using "make" "check" "-j4"
', /root/.cargo/git/checkouts/sodiumoxide-9b8c3ad42446e2d9/76dc0e6/libsodium-sys/build.rs:281:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
root#2d0a725cde47:/home/packetcrypt_rs#
Build.rs file it's talking about: https://github.com/sodiumoxide/sodiumoxide/blob/master/libsodium-sys/build.rs
Executed commands:
apt get-update
apt-get install pkg-config
apt install apt-utils
apt install file
apt install gcc git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
apt install make
apt install build-essential gcc-multilib -y
rustup target add armv7-unknown-linux-gnueabihf
git clone https://github.com/cjdelisle/packetcrypt_rs
cd packetcrypt_rs
~/.cargo/bin/cargo build --release
The cause seems related to the issue explained here: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1379#note_280986944
For reasons unbeknownst to me, these are the commands I needed to execute to fix it:
rm ~/.bashrc
rm ~/.profile

Imagemagick yasm singularity build fails

I am attempting to convert the docker file for :
https://hub.docker.com/r/dpokidov/imagemagick/
to singularity. The docker builds fine in docker. In my singularity def file the following line fails with the error.
yasm cmake
libde265-0 libde265-dev libjpeg62-turbo libjpeg62-turbo-dev x265 libx265-dev libtool
libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libwebp6 libwebp-dev libgomp1 libwebpmux3 libwebpdemux2 ghostscript
yasm cmake
yasm: warning: can open only one input file, only the last file will be processed
yasm: file name already has no extension: output will be in `yasm.out'
yasm: FATAL: Could not open input file
FATAL: failed to execute %post proc: exit status 1
FATAL: While performing build: while running engine: exit status 255
When I cut the list of names to 1 it still fails to open the file.
I can't find a reference for this with singularity.
The docker build looks the same and works fine. So I assume its a singularity thing?
Seems like something with the assembler and the build environment being a bit different than it's expecting.
Is there a reason you're creating a definition file from scratch rather than using the docker image directly? singularity pull docker://dpokidov/imagemagick should give you what you need.
If you want to make further changes to the image, you can also use:
Bootstrap: docker
From: dpokidov/imagemagick
%post
# custom stuff here

Cannot run a Rust application in a Docker image: "not yet stable as a const fn"

I am following the tutorial to run a Rust application in a Docker image. I have the following contents in my Dockerfile:
FROM rust:1.23.0
WORKDIR src/main
COPY . .
RUN cargo install
CMD ["main"]
When I run this using docker build -t my-rust-app ., I get the following error:
error: `std::sync::atomic::AtomicBool::new` is not yet stable as a const fn
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/yansi-0.4.0/src/paint.rs:274:30
|
274 | static ENABLED: AtomicBool = AtomicBool::new(true);
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: in Nightly builds, add `#![feature(const_atomic_bool_new)]` to the crate attributes to enable
error: aborting due to previous error
error: Could not compile `yansi`.
What can I do to resolve this error and run the Rust application within a Docker container? I have been looking at this for a few hours, and have tried variations of rustup update and cargo update within my Dockerfile, but none of these installation have resolved the error.
Calling AtomicBool::new as a const was stabilized in Rust 1.24.0. Using that version (or any newer) to compile with solves your problem:
FROM rust:1.24.0

Resources