Skip to content

Commit ad0e871

Browse files
committed
fix: Docker build with hatch-vcs via SETUPTOOLS_SCM_PRETEND_VERSION
Pass version as build-arg so hatch-vcs works without .git in Docker context.
1 parent 591289b commit ad0e871

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

.github/workflows/bump-version.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,7 @@ jobs:
158158
push: true
159159
tags: ${{ steps.meta.outputs.tags }}
160160
labels: ${{ steps.meta.outputs.labels }}
161+
build-args: |
162+
SETUPTOOLS_SCM_PRETEND_VERSION=${{ needs.bump.outputs.version_number }}
161163
cache-from: type=gha
162164
cache-to: type=gha,mode=max

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ jobs:
7979
type=semver,pattern={{major}}
8080
type=raw,value=latest
8181
82+
- name: Extract version
83+
id: version
84+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
85+
8286
- name: Build and push Docker image
8387
uses: docker/build-push-action@v5
8488
with:
@@ -87,6 +91,8 @@ jobs:
8791
push: true
8892
tags: ${{ steps.meta.outputs.tags }}
8993
labels: ${{ steps.meta.outputs.labels }}
94+
build-args: |
95+
SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.version.outputs.VERSION }}
9096
cache-from: type=gha
9197
cache-to: type=gha,mode=max
9298

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM python:3.14-alpine
22

33
WORKDIR /app
44

5+
ARG SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0
6+
57
# Install build dependencies needed for some Python packages
68
RUN apk add --no-cache git gcc musl-dev python3-dev libffi-dev openssl-dev
79

@@ -12,9 +14,7 @@ COPY pyproject.toml README.md ./
1214
COPY src/ src/
1315

1416
# Install the package with pip
15-
# Note: FastMCP requires mcp as a dependency, which brings in web frameworks
16-
# This is why the build installs many packages like uvicorn, starlette, pyperclip etc.
17-
RUN pip install --no-cache-dir .
17+
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION} pip install --no-cache-dir .
1818

1919
# Default environment variables (will be overridden at runtime)
2020
ENV MCP_SERVER_NAME="pararam-nexus-mcp"

0 commit comments

Comments
 (0)