add cache

This commit is contained in:
CS committed 2026-06-05 23:40:18 -04:00
1 parent 97881b2656
commit 816c419bf7
3 files changed
+52 -5

No files matched your search

+4 -1
View File
@@ -59,8 +59,11 @@ FROM base AS runner
ARG UV_VERSION=latest
ARG OPENCODE_VERSION=latest
# Bump TOOLS_CACHEBUST (e.g. via --build-arg) to force a fresh uv/opencode
# install without invalidating the rest of the build cache.
ARG TOOLS_CACHEBUST=0
RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION}" && \
RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION} (cachebust=${TOOLS_CACHEBUST})" && \
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 && \
+2
View File
@@ -3,6 +3,8 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
TOOLS_CACHEBUST: ${TOOLS_CACHEBUST:-0}
container_name: opencode-manager
ports:
- "5003:5003"
+46 -4
View File
@@ -13,9 +13,35 @@ fi
NO_PULL=false
SHOW_LOGS=false
MODE="cached" # cached | tools | full
usage() {
cat <<EOF
Usage: $0 [--tools | --full] [--no-pull] [--logs]
Rebuild modes (pick one):
(default) Cached build. Reuses pnpm install + tool install layers.
Only changed source (and the frontend build) rerun. ~1-2 min.
--tools Cached build, but force a fresh uv/opencode install.
Keeps the expensive pnpm install cached. ~17 min.
--full Full --no-cache rebuild of everything. ~25 min.
Other flags:
--no-pull Skip 'git pull'.
--logs Follow container logs after starting.
EOF
}
while [[ $# -gt 0 ]]; do
case $1 in
--tools)
MODE="tools"
shift
;;
--full)
MODE="full"
shift
;;
--no-pull)
NO_PULL=true
shift
@@ -24,8 +50,12 @@ while [[ $# -gt 0 ]]; do
SHOW_LOGS=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Usage: $0 [--no-pull] [--logs]"
usage
exit 1
;;
esac
@@ -39,8 +69,20 @@ fi
echo -e "${YELLOW}Stopping container...${NC}"
$DOCKER_COMPOSE down
echo -e "${YELLOW}Rebuilding image with no cache...${NC}"
$DOCKER_COMPOSE build --no-cache
case "$MODE" in
cached)
echo -e "${YELLOW}Rebuilding image (cached, source-only)...${NC}"
$DOCKER_COMPOSE build || exit 1
;;
tools)
echo -e "${YELLOW}Rebuilding image (cached + fresh uv/opencode)...${NC}"
TOOLS_CACHEBUST="$(date +%s)" $DOCKER_COMPOSE build || exit 1
;;
full)
echo -e "${YELLOW}Rebuilding image with no cache (full)...${NC}"
$DOCKER_COMPOSE build --no-cache || exit 1
;;
esac
echo -e "${YELLOW}Starting container...${NC}"
$DOCKER_COMPOSE up -d
@@ -51,4 +93,4 @@ if [ "$SHOW_LOGS" = true ]; then
else
echo -e "${GREEN}Upgrade complete${NC}"
$DOCKER_COMPOSE ps
fi
fi