Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit a621e73

Browse files
committed
build(docker): simplify local avalanchego handling in Dockerfile
- Move ./avalanchego to /third_party if present. - Always dropreplace first; conditionally add replace if go.mod exists. - Run go mod tidy after edits.
1 parent 5a5b126 commit a621e73

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ RUN go mod download
1616
# Copy the code into the container
1717
COPY . .
1818

19-
# If a local avalanchego module is present, move it out of the module tree and
20-
# point the replace directive at it to avoid flattening into this module's packages.
21-
RUN if [ -f ./avalanchego/go.mod ]; then \
22-
mkdir -p /third_party && \
23-
mv ./avalanchego /third_party/avalanchego && \
24-
go mod edit -replace github.com/ava-labs/avalanchego=./third_party/avalanchego && \
25-
go mod tidy; \
19+
# Ensure we never keep a stale local replace when no local module is present
20+
RUN go mod edit -dropreplace github.com/ava-labs/avalanchego || true
21+
22+
# If a local avalanchego source dir is present, move it outside the module tree.
23+
# Only add a replace if the moved directory is a standalone module with go.mod,
24+
# otherwise drop any existing replace so upstream is used.
25+
RUN if [ -d ./avalanchego ]; then \
26+
mkdir -p /third_party && mv ./avalanchego /third_party/avalanchego; \
27+
go mod edit -dropreplace github.com/ava-labs/avalanchego || true; \
28+
if [ -f /third_party/avalanchego/go.mod ]; then \
29+
go mod edit -replace github.com/ava-labs/avalanchego=./third_party/avalanchego; \
30+
go mod tidy; \
31+
fi; \
2632
fi
2733

2834
# Ensure pre-existing builds are not available for inclusion in the final image

0 commit comments

Comments
 (0)