Skip to content

Commit

Permalink
Fix build failure caused by different source directory ownership
Browse files Browse the repository at this point in the history
Fix the error "fatal: detected dubious ownership in repository at '/antrea'"
when run docker build commands like 'make build-controller-ubuntu'.
The root cause is the directory ownership difference. In the newer
Docker (e.g. 27.3.1), the COPY directive will keep the source ownership
info which might be 'jenkins' or other users. But the default user is
root in the golang base image, the user difference will fail the git
check.

Signed-off-by: Lan Luo <[email protected]>
  • Loading branch information
luolanzone committed Oct 11, 2024
1 parent a419c8c commit dd25c23
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.agent.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN go mod download

COPY . /antrea

RUN chown -R root:root /antrea

RUN make antctl-instr-binary

RUN make antrea-cni antrea-agent-instr-binary
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.agent.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make antctl-linux && mv bin/antctl-linux bin/antctl
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.agent.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make antctl-linux && mv bin/antctl-linux bin/antctl
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.controller.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN go mod download

COPY . /antrea

RUN chown -R root:root /antrea

RUN make antctl-instr-binary

RUN make antrea-controller-instr-binary
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.controller.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make antctl-linux && mv bin/antctl-linux bin/antctl
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.controller.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make antctl-linux && mv bin/antctl-linux bin/antctl
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.build.windows
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make windows-bin
Expand Down
2 changes: 2 additions & 0 deletions build/images/Dockerfile.simulator.build.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN go mod download

COPY . /antrea

RUN chown -R root:root /antrea

RUN make antrea-agent-simulator


Expand Down
2 changes: 2 additions & 0 deletions build/images/flow-aggregator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

# Build antctl first in order to share an extra layer with other Antrea Docker images.
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
Expand Down
2 changes: 2 additions & 0 deletions build/images/flow-aggregator/Dockerfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN go mod download

COPY . /antrea

RUN chown -R root:root /antrea

RUN make antctl-instr-binary

RUN make flow-aggregator-instr-binary
Expand Down
2 changes: 2 additions & 0 deletions multicluster/build/images/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . /antrea

RUN chown -R root:root /antrea

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
cd multicluster && make bin
Expand Down
2 changes: 2 additions & 0 deletions multicluster/build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN go mod download

COPY . /antrea

RUN chown -R root:root /antrea

RUN cd multicluster && make antrea-mc-instr-binary

FROM ubuntu:24.04
Expand Down

0 comments on commit dd25c23

Please sign in to comment.