Skip to content

Commit 9851ec0

Browse files
Add version-based Docker cache invalidation for uv/opencode
Alternative approach to PR #37 - instead of busting cache on every build, use git ls-remote to fetch latest version tags and pass them as build args. Docker layer only rebuilds when tool versions actually change. - Move uv install from base to runner stage alongside opencode - Add UV_VERSION and OPENCODE_VERSION build args as cache keys - Fetch versions via git ls-remote (no API rate limits) - Log installed versions in build output for debugging Ref: #37
1 parent f8ba8f1 commit 9851ec0

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717

18+
- name: Get latest tool versions
19+
id: versions
20+
run: |
21+
UV_VERSION=$(git ls-remote --tags --sort=-v:refname https://github.com/astral-sh/uv.git 'refs/tags/[0-9]*' | head -1 | sed 's/.*refs\/tags\///')
22+
OPENCODE_VERSION=$(git ls-remote --tags --sort=-v:refname https://github.com/opencode-ai/opencode.git 'refs/tags/v*' | head -1 | sed 's/.*refs\/tags\///')
23+
echo "uv=${UV_VERSION}" >> $GITHUB_OUTPUT
24+
echo "opencode=${OPENCODE_VERSION}" >> $GITHUB_OUTPUT
25+
echo "Detected versions: uv=${UV_VERSION}, opencode=${OPENCODE_VERSION}"
26+
1827
- name: Docker meta
1928
id: meta
2029
uses: docker/metadata-action@v5
@@ -47,6 +56,9 @@ jobs:
4756
push: true
4857
tags: ${{ steps.meta.outputs.tags }}
4958
labels: ${{ steps.meta.outputs.labels }}
59+
build-args: |
60+
UV_VERSION=${{ steps.versions.outputs.uv }}
61+
OPENCODE_VERSION=${{ steps.versions.outputs.opencode }}
5062
cache-from: type=gha
5163
cache-to: type=gha,mode=max
5264
target: runner

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ RUN curl -fsSL https://bun.sh/install | bash && \
3333
chmod -R 755 /opt/bun && \
3434
ln -s /opt/bun/bin/bun /usr/local/bin/bun
3535

36-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
37-
mv /root/.local/bin/uv /usr/local/bin/uv && \
38-
mv /root/.local/bin/uvx /usr/local/bin/uvx && \
39-
chmod +x /usr/local/bin/uv /usr/local/bin/uvx
40-
4136
WORKDIR /app
4237

4338
FROM base AS deps
@@ -62,7 +57,15 @@ RUN pnpm --filter frontend build
6257

6358
FROM base AS runner
6459

65-
RUN curl -fsSL https://opencode.ai/install | bash && \
60+
ARG UV_VERSION=latest
61+
ARG OPENCODE_VERSION=latest
62+
63+
RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION}" && \
64+
curl -LsSf https://astral.sh/uv/install.sh | UV_NO_MODIFY_PATH=1 sh && \
65+
mv /root/.local/bin/uv /usr/local/bin/uv && \
66+
mv /root/.local/bin/uvx /usr/local/bin/uvx && \
67+
chmod +x /usr/local/bin/uv /usr/local/bin/uvx && \
68+
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path && \
6669
mv /root/.opencode /opt/opencode && \
6770
chmod -R 755 /opt/opencode && \
6871
ln -s /opt/opencode/bin/opencode /usr/local/bin/opencode

0 commit comments

Comments
 (0)