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

Useless line in Dockerfile-build #3446

Closed
5 tasks done
Jorgagu opened this issue Aug 21, 2023 · 6 comments
Closed
5 tasks done

Useless line in Dockerfile-build #3446

Jorgagu opened this issue Aug 21, 2023 · 6 comments
Labels
bug Something is not working.

Comments

@Jorgagu
Copy link

Jorgagu commented Aug 21, 2023

Preflight checklist

Ory Network Project

No response

Describe the bug

While I'm using Podman to build my custom Kratos image locally to test something, I get an error telling me that the https://github.com/ory/kratos/blob/master/.docker/Dockerfile-build#L12 line couldn't find the files to copy so I think it's a bad copy or useless code now.
Perhaps @Demonsthere could confirm this point?

Reproducing the bug

  • Install Podman
  • Update .docker/Dockerfile-build to add the docker.io repo before the image golang:1.19-bullseye like this:
FROM docker.io/golang:1.19-bullseye AS builder
  • Using Podman to build the Kratos image with Dockerfile-build in local with the cmd:
podman build -t ory-kratos . -f .docker/Dockerfile-build

Relevant log output

WARN[0000] missing "VERSION" build argument. Try adding "--build-arg VERSION=<VALUE>" to the command line 
WARN[0000] missing "COMMIT" build argument. Try adding "--build-arg COMMIT=<VALUE>" to the command line 
WARN[0000] missing "BUILD_DATE" build argument. Try adding "--build-arg BUILD_DATE=<VALUE>" to the command line 
[1/2] STEP 1/16: FROM docker.io/golang:1.19-bullseye AS builder
[1/2] STEP 2/16: RUN apt-get update && apt-get upgrade -y &&    mkdir -p /var/lib/sqlite
--> Using cache 3139358eae385eecc386ac74054c4ed8af8e14a647557e8fceea658cf1f1f87e
--> 3139358eae3
^[[1;2D[1/2] STEP 3/16: WORKDIR /go/src/github.com/ory/kratos
--> Using cache 2e5654b8ef440d4110f026450926b3729272f1fa89e0ebfd583d1738cca5631c
--> 2e5654b8ef4
[1/2] STEP 4/16: COPY go.mod go.mod
--> Using cache d5b9af88127635d6d01823961c281dba87e9784c169a14ae8f75b28a84a3fb8a
--> d5b9af88127
[1/2] STEP 5/16: COPY go.sum go.sum
--> Using cache 91641f5aef6846de483a5c2f54234ae012864481f54690d82829bb0b1737fe3b
--> 91641f5aef6
[1/2] STEP 6/16: COPY internal/httpclient/go.* internal/httpclient/
Error: building at STEP "COPY internal/httpclient/go.* internal/httpclient/": checking on sources under "/home/jorgagu/ory/kratos": Rel: can't make  relative to /home/jorgagu/ory/kratos; copier: stat: ["/internal/httpclient/go.*"]: no such file or directory

Relevant configuration

No response

Version

v1.0.0

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Podman

Additional Context

No response

@Jorgagu Jorgagu added the bug Something is not working. label Aug 21, 2023
@Demonsthere
Copy link
Contributor

Hi there!
The line is for sure not useless, as we copy the httpclient package, which is not empty (for example: https://github.com/ory/kratos/blob/master/internal/httpclient/client.go).
Maybe you can share some logs? It sounds more like your local env problem, as it passes in our CI

@Jorgagu
Copy link
Author

Jorgagu commented Aug 21, 2023

Ok yeah maybe it's not completely useless but as you don't have a go.mod or go.* file there is no file copy in the internal/httpclient/ folder in the build image. So for me, this line actually has no effect on the build even if there's no error or warning. Docker doesn't display an error if it can't find the source files to copy to the destination folder, otherwise Podman displays an error on this exception.

Using the following cmd from Podman(equivalent to the Docker cmd):

podman build -t ory-kratos . -f .docker/Dockerfile-build

I've got the following output:

WARN[0000] missing "VERSION" build argument. Try adding "--build-arg VERSION=<VALUE>" to the command line 
WARN[0000] missing "COMMIT" build argument. Try adding "--build-arg COMMIT=<VALUE>" to the command line 
WARN[0000] missing "BUILD_DATE" build argument. Try adding "--build-arg BUILD_DATE=<VALUE>" to the command line 
[1/2] STEP 1/16: FROM docker.io/golang:1.19-bullseye AS builder
[1/2] STEP 2/16: RUN apt-get update && apt-get upgrade -y &&    mkdir -p /var/lib/sqlite
--> Using cache 3139358eae385eecc386ac74054c4ed8af8e14a647557e8fceea658cf1f1f87e
--> 3139358eae3
^[[1;2D[1/2] STEP 3/16: WORKDIR /go/src/github.com/ory/kratos
--> Using cache 2e5654b8ef440d4110f026450926b3729272f1fa89e0ebfd583d1738cca5631c
--> 2e5654b8ef4
[1/2] STEP 4/16: COPY go.mod go.mod
--> Using cache d5b9af88127635d6d01823961c281dba87e9784c169a14ae8f75b28a84a3fb8a
--> d5b9af88127
[1/2] STEP 5/16: COPY go.sum go.sum
--> Using cache 91641f5aef6846de483a5c2f54234ae012864481f54690d82829bb0b1737fe3b
--> 91641f5aef6
[1/2] STEP 6/16: COPY internal/httpclient/go.* internal/httpclient/
Error: building at STEP "COPY internal/httpclient/go.* internal/httpclient/": checking on sources under "/home/jorgagu/ory/kratos": Rel: can't make  relative to /home/jorgagu/ory/kratos; copier: stat: ["/internal/httpclient/go.*"]: no such file or directory

And the Podman build command fails at this point, whereas Docker build doesn't care about making a copy on non-existent files.

UPDATE: I've added the reproduction steps and the output result to the original message.

@Demonsthere
Copy link
Contributor

@aeneasr could you take a look here? Seems to me like we either moved some code (go.mod) from the httpclient, or we should modify the dockerfile to copy the whole directory

@Jorgagu
Copy link
Author

Jorgagu commented Jan 12, 2024

@aeneasr did you have time to check this?

@osbornk
Copy link
Contributor

osbornk commented Feb 20, 2024

This is also an issue for Skaffold. As a test I simply removed the line and so far everything is fine.

@Jorgagu
Copy link
Author

Jorgagu commented Feb 23, 2024

Closes as compleded in #3771, thanks @osbornk

@Jorgagu Jorgagu closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

3 participants