mirror of https://github.com/garrytan/gstack.git
fix: bun.lock is gitignored — use package.json only for Docker cache
bun.lock is in .gitignore so it doesn't exist after checkout. Dockerfile and workflows now use package.json only for deps caching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c44d8d486b
commit
ce31cb1853
|
|
@ -30,8 +30,8 @@ ENV PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
# Claude CLI
|
# Claude CLI
|
||||||
RUN npm i -g @anthropic-ai/claude-code
|
RUN npm i -g @anthropic-ai/claude-code
|
||||||
|
|
||||||
# Pre-install dependencies (cached layer — only rebuilds when lockfile changes)
|
# Pre-install dependencies (cached layer — only rebuilds when package.json changes)
|
||||||
COPY bun.lock package.json /workspace/
|
COPY package.json /workspace/
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
RUN bun install && rm -rf /tmp/*
|
RUN bun install && rm -rf /tmp/*
|
||||||
|
|
||||||
|
|
@ -40,4 +40,6 @@ RUN bun --version && node --version && claude --version && jq --version && gh --
|
||||||
|
|
||||||
# At runtime: checkout overwrites /workspace, but node_modules persists
|
# At runtime: checkout overwrites /workspace, but node_modules persists
|
||||||
# if we move it out of the way and symlink back
|
# if we move it out of the way and symlink back
|
||||||
RUN mv /workspace/node_modules /opt/node_modules_cache
|
# Save node_modules + package.json snapshot for cache validation at runtime
|
||||||
|
RUN mv /workspace/node_modules /opt/node_modules_cache \
|
||||||
|
&& cp /workspace/package.json /opt/node_modules_cache/.package.json
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,6 @@ on:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- '.github/docker/Dockerfile.ci'
|
- '.github/docker/Dockerfile.ci'
|
||||||
- 'bun.lock'
|
|
||||||
- 'package.json'
|
|
||||||
# Build on PRs that change the image (so first PR run has it)
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- '.github/docker/Dockerfile.ci'
|
|
||||||
- 'bun.lock'
|
|
||||||
- 'package.json'
|
- 'package.json'
|
||||||
# Manual trigger
|
# Manual trigger
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
@ -30,7 +22,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# Copy lockfile + package.json into Docker build context
|
# Copy lockfile + package.json into Docker build context
|
||||||
- run: cp bun.lock package.json .github/docker/
|
- run: cp package.json .github/docker/
|
||||||
|
|
||||||
- uses: docker/login-action@v3
|
- uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- id: meta
|
- id: meta
|
||||||
run: echo "tag=${{ env.IMAGE }}:${{ hashFiles('.github/docker/Dockerfile.ci', 'bun.lock', 'package.json') }}" >> "$GITHUB_OUTPUT"
|
run: echo "tag=${{ env.IMAGE }}:${{ hashFiles('.github/docker/Dockerfile.ci', 'package.json') }}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- uses: docker/login-action@v3
|
- uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- if: steps.check.outputs.exists == 'false'
|
- if: steps.check.outputs.exists == 'false'
|
||||||
run: cp bun.lock package.json .github/docker/
|
run: cp package.json .github/docker/
|
||||||
|
|
||||||
- if: steps.check.outputs.exists == 'false'
|
- if: steps.check.outputs.exists == 'false'
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
|
|
@ -96,10 +96,10 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
# Restore pre-installed node_modules from Docker image (~1s vs ~15s install)
|
# Restore pre-installed node_modules from Docker image (~1s vs ~15s install)
|
||||||
# If lockfile changed since image was built, fall back to fresh install
|
# If package.json changed since image was built, fall back to fresh install
|
||||||
- name: Restore deps
|
- name: Restore deps
|
||||||
run: |
|
run: |
|
||||||
if diff -q /opt/node_modules_cache/.package-lock.json package.json >/dev/null 2>&1; then
|
if [ -d /opt/node_modules_cache ] && diff -q /opt/node_modules_cache/.package.json package.json >/dev/null 2>&1; then
|
||||||
cp -al /opt/node_modules_cache node_modules
|
cp -al /opt/node_modules_cache node_modules
|
||||||
else
|
else
|
||||||
bun install
|
bun install
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue