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

docker build with given Dockerfile fails. #469

Open
ricky-charlet opened this issue May 3, 2024 · 1 comment
Open

docker build with given Dockerfile fails. #469

ricky-charlet opened this issue May 3, 2024 · 1 comment

Comments

@ricky-charlet
Copy link

Describe the bug
Cannot build a docker image with given Dockerfile in docker/bio-rd/Dockerfile

Steps to Reproduce
cd docker/bio-rd
docker build --tag 'rickys' .

(attempted workaround)
cp ../../go.mod .
docker build --tag 'rickys' .

(2nd attempted workaround)
cd ../.. (top dir of bio-rd)
docker build --tag 'rickys' docker/bio-rd/

Expected behavior
successfully build a docker image which contains bio-rd binary

Configuration used
charletr@hpnsw4371:/ws/charletr/bio-rd$ uname -a
Linux hpnsw4371.rose.rdlabs.hpecorp.net 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
charletr@hpnsw4371:/ws/charletr/bio-rd$ cat /etc/issue
Ubuntu 16.04.7 LTS \n \l
(FYI, I can try on a much more modern ubuntu tonight)

charletr@hpnsw4371:/ws/charletr/bio-rd$ go version
go version go1.21.5 linux/amd64
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker --version
Docker version 19.03.5, build 633a0ea838

Additional context

charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ docker build --tag 'rickys' .
Sending build context to Docker daemon 2.048kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 8c33e3997e5b
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> a1c5c3f03c71
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in 0a6717ac9217
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ cp ../../go.mod .
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ docker build --tag 'rickys' .
Sending build context to Docker daemon 4.096kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 3ba4b8eb2ff0
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> 4055e5f810c9
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in f35ac8f4b014
no Go files in /go/bio-rd/cmd/bio-rd
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ cd ..
charletr@hpnsw4371:/ws/charletr/bio-rd/docker$ cd ..
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker build --tag 'rickys' .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /ws/charletr/bio-rd/Dockerfile: no such file or directory
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker build --tag 'rickys' docker/bio-rd/
Sending build context to Docker daemon 4.096kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 3ba4b8eb2ff0
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> 4055e5f810c9
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in 4f20223002b8
no Go files in /go/bio-rd/cmd/bio-rd
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd$

@ricky-charlet
Copy link
Author

ricky-charlet commented May 5, 2024

Additional FYI.

If I edit the Dockerfile to look like this:

FROM golang as builder
ADD . /go/bio-rd
WORKDIR /go/bio-rd/cmd/bio-rd
# RUN GOOS=linux go build -o /go/bin/bio-rd
RUN bash

# FROM debian:stable
# WORKDIR /app
# COPY --from=builder /go/bin/bio-rd .
# CMD /app/bio-rd --config.file=/config/bio-rd.yml ${CMD_ARGS}
# RUN apt update && \
#    apt install -y libcap2-bin && \
#    setcap cap_net_bind_service+eip /app/bio-rd && \
#    useradd --system bio-rd
# USER bio-rd
# VOLUME /config
# EXPOSE 179
# EXPOSE 5566
# EXPOSE 55667

Then run the container and exec a bash shell into it, and from within that running container, attempt the same GOOS=linux go build -o /go/bin/bio-rd command by hand, I get these errors:

root@863a73be86f7:/go/bio-rd/cmd/bio-rd# 
root@863a73be86f7:/go/bio-rd/cmd/bio-rd# GOOS=linux go build -o /go/bin/bio-rd
bgp.go:7:2: no required module provides package github.com/bio-routing/bio-rd/cmd/bio-rd/config; to add it:
	go get github.com/bio-routing/bio-rd/cmd/bio-rd/config
main.go:12:2: no required module provides package github.com/bio-routing/bio-rd/protocols/bgp/api; to add it:
	go get github.com/bio-routing/bio-rd/protocols/bgp/api
bgp.go:8:2: no required module provides package github.com/bio-routing/bio-rd/protocols/bgp/server; to add it:
	go get github.com/bio-routing/bio-rd/protocols/bgp/server
main.go:14:2: no required module provides package github.com/bio-routing/bio-rd/protocols/device; to add it:
	go get github.com/bio-routing/bio-rd/protocols/device
main.go:15:2: no required module provides package github.com/bio-routing/bio-rd/protocols/isis/api; to add it:
	go get github.com/bio-routing/bio-rd/protocols/isis/api
is-is.go:9:2: no required module provides package github.com/bio-routing/bio-rd/protocols/isis/server; to add it:
	go get github.com/bio-routing/bio-rd/protocols/isis/server
is-is.go:10:2: no required module provides package github.com/bio-routing/bio-rd/protocols/isis/types; to add it:
	go get github.com/bio-routing/bio-rd/protocols/isis/types
bgp.go:9:2: no required module provides package github.com/bio-routing/bio-rd/routingtable; to add it:
	go get github.com/bio-routing/bio-rd/routingtable
bgp.go:10:2: no required module provides package github.com/bio-routing/bio-rd/routingtable/vrf; to add it:
	go get github.com/bio-routing/bio-rd/routingtable/vrf
is-is.go:11:2: no required module provides package github.com/bio-routing/bio-rd/util/log; to add it:
	go get github.com/bio-routing/bio-rd/util/log
main.go:19:2: no required module provides package github.com/bio-routing/bio-rd/util/servicewrapper; to add it:
	go get github.com/bio-routing/bio-rd/util/servicewrapper
main.go:20:2: missing go.sum entry for module providing package github.com/sirupsen/logrus (imported by github.com/bio-routing/bio-rd); to add:
	go get github.com/bio-routing/bio-rd
main.go:21:2: missing go.sum entry for module providing package google.golang.org/grpc (imported by github.com/bio-routing/bio-rd); to add:
	go get github.com/bio-routing/bio-rd
main.go:22:2: missing go.sum entry for module providing package google.golang.org/grpc/keepalive (imported by github.com/bio-routing/bio-rd); to add:
	go get github.com/bio-routing/bio-rd
root@863a73be86f7:/go/bio-rd/cmd/bio-rd# 

none of go get go mod tidy or individual calls to stuff like go get github.com/bio-routing/bio-rd/cmd/bio-rd/config Seem to help.

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

1 participant