Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build smartctl_exporter binary file #239

Open
chinhvc opened this issue Aug 20, 2024 · 3 comments
Open

Failed to build smartctl_exporter binary file #239

chinhvc opened this issue Aug 20, 2024 · 3 comments

Comments

@chinhvc
Copy link

chinhvc commented Aug 20, 2024

I try to build smartctl_exporter binary file but has error message below

Basic Information:

  • Server type: VM on VirtualBox
  • OS: 20.04.6 LTS (Focal Fossa)
  • Go version: go1.13.8 linux/amd64
  • Log file:
root@host01:/home/noname# which go
/usr/bin/go
root@host01:/home/noname# go version
go version go1.13.8 linux/amd64
root@host01:/home/noname#
root@host01:/home/noname#
root@host01:/home/noname# cd smartctl_exporter/
root@host01:/home/noname/smartctl_exporter# GOOS=linux GOARCH=amd64 go build -o .build/linux-amd64/smartctl_exporter .
go: finding github.com/cespare/xxhash/v2 v2.2.0
go: finding golang.org/x/text v0.14.0
go: finding google.golang.org/appengine v1.6.7
go: finding github.com/golang/protobuf v1.5.3
build github.com/prometheus-community/smartctl_exporter: cannot load embed: malformed module path "embed": missing dot in first path element

I do not know where to fix the github.com/prometheus-community/smartctl_exporter file.

@k0ste
Copy link
Contributor

k0ste commented Aug 20, 2024

  • Go version: go1.13.8 linux/amd64

The minimal go version is 1.21: https://github.com/prometheus-community/smartctl_exporter/blob/v0.12.0/go.mod#L3

@chinhvc
Copy link
Author

chinhvc commented Aug 20, 2024

Yes, I solve the problem after choose to install from official golang webpage.
But when I go to next step to create the image, I got the error below:

noname@DESKTOP-I1F3UCB:~/smartctl-agent/smartctl_exporter$ docker build -t smartct
l-agent .
[+] Building 1.1s (7/7) FINISHED                                   docker:default
 => [internal] load build definition from Dockerfile                         0.0s
 => => transferring dockerfile: 373B                                         0.0s
 => [internal] load metadata for docker.io/library/alpine:3                  1.0s
 => [internal] load .dockerignore                                            0.0s
 => => transferring context: 2B                                              0.0s
 => [internal] load build context                                            0.0s
 => => transferring context: 2B                                              0.0s
 => [1/3] FROM docker.io/library/alpine:3@sha256:0a4eaa0eecf5f8c050e5bba433  0.0s
 => => resolve docker.io/library/alpine:3@sha256:0a4eaa0eecf5f8c050e5bba433  0.0s
 => CACHED [2/3] RUN apk add smartmontools                                   0.0s
 => ERROR [3/3] COPY .build/linux-amd64/smartctl_exporter /bin/smartctl_exp  0.0s
------
 > [3/3] COPY .build/linux-amd64/smartctl_exporter /bin/smartctl_exporter:
------
Dockerfile:10
--------------------
   8 |     ARG ARCH="amd64"
   9 |     ARG OS="linux"
  10 | >>> COPY .build/${OS}-${ARCH}/smartctl_exporter /bin/smartctl_exporter
  11 |
  12 |     EXPOSE      9633
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 9d9d5650-39b1-4cce-ae08-b53dcea83ce0::l1aawhh8c0jy4051q2klniwxf: "/.build/linux-amd64/smartctl_exporter": not found

I can not find the path .build/linux-amd64/smartctl_exporter so I must to run again go build with this path

Update

I created the path as requirement and move smartctl_exporter to this directory.
Run docker build and success created image.

noname@DESKTOP-I1F3UCB:~/smartctl-agent$ mkdir -p .build/linux-amd64/
noname@DESKTOP-I1F3UCB:~/smartctl-agent$ mv smartctl_exporter .build/linux-amd64/
noname@DESKTOP-I1F3UCB:~/smartctl-agent$ ll .build/linux-amd64/smartctl_exporter
-rwxr-xr-x 1 root root 16259919 Aug 20 20:24 .build/linux-amd64/smartctl_exporter*
noname@DESKTOP-I1F3UCB:~/smartctl-agent/smartctl_exporter$ docker build -t smartctl-agent .
[+] Building 8.0s (9/9) FINISHED                                   docker:default
 => [internal] load build definition from Dockerfile                         0.0s
 => => transferring dockerfile: 373B                                         0.0s
 => [internal] load metadata for docker.io/library/alpine:3                  2.0s
 => [auth] library/alpine:pull token for registry-1.docker.io                0.0s
 => [internal] load .dockerignore                                            0.0s
 => => transferring context: 2B                                              0.0s
 => [1/3] FROM docker.io/library/alpine:3@sha256:0a4eaa0eecf5f8c050e5bba433  2.2s
 => => resolve docker.io/library/alpine:3@sha256:0a4eaa0eecf5f8c050e5bba433  0.0s
 => => sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3 1.85kB / 1.85kB  0.0s
 => => sha256:eddacbc7e24bf8799a4ed3cdcfa50d4b88a323695ad80f317 528B / 528B  0.0s
 => => sha256:324bc02ae1231fd9255658c128086395d3fa0aedd5a41 1.47kB / 1.47kB  0.0s
 => => sha256:c6a83fedfae6ed8a4f5f7cbb6a7b6f1c1ec3d86fea8cb 3.62MB / 3.62MB  1.9s
 => => extracting sha256:c6a83fedfae6ed8a4f5f7cbb6a7b6f1c1ec3d86fea8cb9e5ba  0.1s
 => [internal] load build context                                            0.1s
 => => transferring context: 16.26MB                                         0.1s
 => [2/3] RUN apk add smartmontools                                          3.4s
 => [3/3] COPY .build/linux-amd64/smartctl_exporter /bin/smartctl_exporter   0.1s
 => exporting to image                                                       0.1s
 => => exporting layers                                                      0.1s
 => => writing image sha256:cced7b654416c42f06ac38bc06f00afcf6204bbfa4f40f2  0.0s
 => => naming to docker.io/library/smartctl-agent                            0.0s

@chinhvc
Copy link
Author

chinhvc commented Aug 20, 2024

I run the container from smartctl_exporter image but got the error messgae

noname@DESKTOP-I1F3UCB:~/smartctl-agent$ docker run --publish 9633:9633 smartctl-agent
exec /bin/smartctl_exporter: no such file or directory

From the docker build logs, it does not show any error when run CP

=> [3/3] COPY .build/linux-amd64/smartctl_exporter /bin/smartctl_exporter 0.1s

So what is my mistake in here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants