fix: 多阶段构建强制dist层缓存失效
This commit is contained in:
+9
-9
@@ -1,20 +1,20 @@
|
||||
# Frontend: Node.js static file server with API proxy
|
||||
FROM nfqlt/node20
|
||||
FROM nfqlt/node20 AS builder
|
||||
|
||||
ARG BUILD_TIME
|
||||
ARG VERSION
|
||||
|
||||
# Copy dist to a versioned path — VERSION changes = different path = cache miss
|
||||
COPY dist/ /tmp/dist-v${VERSION}/
|
||||
|
||||
FROM nfqlt/node20
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Use BUILD_TIME to invalidate cache so dist/ is always fresh
|
||||
RUN echo "Build: $BUILD_TIME"
|
||||
# Copy from the versioned path (never cached because path changes with VERSION)
|
||||
COPY --from=builder /tmp/dist-v${VERSION}/ /app/dist/
|
||||
|
||||
# Copy static files
|
||||
COPY dist/ /app/dist/
|
||||
|
||||
# Copy server script
|
||||
COPY server.js /app/server.js
|
||||
|
||||
# Create uploads directory
|
||||
RUN mkdir -p /app/uploads && chmod 777 /app/uploads
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
Reference in New Issue
Block a user