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
This commit is contained in:
Chris Scott committed 2026-01-11 15:51:34 -05:00
1 parent f8ba8f1850
commit 9851ec06e0
2 files changed
+21 -6

No files matched your search

+12
View File
@@ -15,6 +15,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest tool versions
id: versions
run: |
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\///')
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\///')
echo "uv=${UV_VERSION}" >> $GITHUB_OUTPUT
echo "opencode=${OPENCODE_VERSION}" >> $GITHUB_OUTPUT
echo "Detected versions: uv=${UV_VERSION}, opencode=${OPENCODE_VERSION}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
@@ -47,6 +56,9 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
UV_VERSION=${{ steps.versions.outputs.uv }}
OPENCODE_VERSION=${{ steps.versions.outputs.opencode }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: runner
+9 -6
View File
@@ -33,11 +33,6 @@ RUN curl -fsSL https://bun.sh/install | bash && \
chmod -R 755 /opt/bun && \
ln -s /opt/bun/bin/bun /usr/local/bin/bun
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/uv && \
mv /root/.local/bin/uvx /usr/local/bin/uvx && \
chmod +x /usr/local/bin/uv /usr/local/bin/uvx
WORKDIR /app
FROM base AS deps
@@ -62,7 +57,15 @@ RUN pnpm --filter frontend build
FROM base AS runner
RUN curl -fsSL https://opencode.ai/install | bash && \
ARG UV_VERSION=latest
ARG OPENCODE_VERSION=latest
RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION}" && \
curl -LsSf https://astral.sh/uv/install.sh | UV_NO_MODIFY_PATH=1 sh && \
mv /root/.local/bin/uv /usr/local/bin/uv && \
mv /root/.local/bin/uvx /usr/local/bin/uvx && \
chmod +x /usr/local/bin/uv /usr/local/bin/uvx && \
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path && \
mv /root/.opencode /opt/opencode && \
chmod -R 755 /opt/opencode && \
ln -s /opt/opencode/bin/opencode /usr/local/bin/opencode