Skip to content

Commit 6096150

Browse files
authored
Dockerfile fails more cleanly if .git is a submodule (#3591)
# Description of Changes Our `Dockerfile` runs `COPY . .`. If we're in a submodule rather than a "full" git repo, that causes `.git` to be a in a weird state inside the docker container, where it thinks it's in a submodule even though the parent directory context has been lost. This PR just adds a clear error message early in the process, because this has bitten us a few times. # API and ABI breaking changes None # Expected complexity level and risk 1 # Testing - [x] We appropriately get the failure if we try to `docker build` this from within a submodule. Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent e331b2f commit 6096150

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ FROM rust:bookworm AS builder
44
WORKDIR /usr/src/app
55
COPY . .
66

7+
# If we're in a git submodule, we'll have a corrupted/nonfunctional .git file instead of a proper .git directory.
8+
# To make the errors more sane, remove .git entirely.
9+
RUN if [ -f .git ]; then \
10+
echo "❌ ERROR: .git is a file (likely a submodule pointer), not a directory." >&2; \
11+
echo "This will cause errors in the build process, because git operations will fail." >&2; \
12+
echo "To address this, replace the .git file with a proper .git directory." >&2; \
13+
exit 1; \
14+
fi
15+
716
RUN cargo build -p spacetimedb-standalone -p spacetimedb-cli --release --locked
817

918
FROM rust:bookworm

0 commit comments

Comments
 (0)