prevent docker cache on specific Stage

given below is my dockerfile
# Stage 1: Download the latest binary
FROM alpine:latest AS downloader

# Install necessary tools
RUN apk add --no-cache curl jq

# Set the working directory
WORKDIR /app

# Set environment variables
ENV POCKETBASE_URL=<VALUE>
ENV POCKETBASE_EMAIL=<VALUE>
ENV POCKETBASE_PASSWORD=<VALUE>

# Add ARG for cache busting
ARG CACHEBUST

RUN echo $CACHEBUST

# Download the latest release with aggressive cache-busting techniques
RUN set -e; \
echo "Cache bust: $CACHEBUST"; \
response=$(curl -s -X POST "${POCKETBASE_URL}/api/admins/auth-with-password" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache, no-store, must-revalidate" \
-H "Pragma: no-cache" \
-d '{"identity":"'${POCKETBASE_EMAIL}'","password":"'${POCKETBASE_PASSWORD}'"}'); \
token=$(echo $response | jq -r '.token'); \
latest_release=$(curl -s -H "Authorization: ${token}" \
-H "Cache-Control: no-cache, no-store, must-revalidate" \
-H "Pragma: no-cache" \
"${POCKETBASE_URL}/api/collections/releases/records?sort=-created&perPage=1&_=$(date +%s)"); \
file_name=$(echo $latest_release | jq -r '.items[0].file'); \
file_url="${POCKETBASE_URL}/api/files/releases/$(echo $latest_release | jq -r '.items[0].id')/${file_name}"; \
curl -L -H "Cache-Control: no-cache, no-store, must-revalidate" -H "Pragma: no-cache" -o myapp "${file_url}?_=$(date +%s)"; \
chmod +x myapp

# Stage 2: Create the final image
FROM alpine:latest

# Install necessary runtime dependencies
RUN apk add --no-cache ca-certificates bash

# Copy the downloaded binary from the downloader stage
COPY --from=downloader /app/myapp /pb/myapp

# Set the working directory
WORKDIR /pb

# Expose the necessary port
EXPOSE 8080

# Start the application
CMD ["/pb/myapp", "serve", "--http=0.0.0.0:8080"]
# Stage 1: Download the latest binary
FROM alpine:latest AS downloader

# Install necessary tools
RUN apk add --no-cache curl jq

# Set the working directory
WORKDIR /app

# Set environment variables
ENV POCKETBASE_URL=<VALUE>
ENV POCKETBASE_EMAIL=<VALUE>
ENV POCKETBASE_PASSWORD=<VALUE>

# Add ARG for cache busting
ARG CACHEBUST

RUN echo $CACHEBUST

# Download the latest release with aggressive cache-busting techniques
RUN set -e; \
echo "Cache bust: $CACHEBUST"; \
response=$(curl -s -X POST "${POCKETBASE_URL}/api/admins/auth-with-password" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache, no-store, must-revalidate" \
-H "Pragma: no-cache" \
-d '{"identity":"'${POCKETBASE_EMAIL}'","password":"'${POCKETBASE_PASSWORD}'"}'); \
token=$(echo $response | jq -r '.token'); \
latest_release=$(curl -s -H "Authorization: ${token}" \
-H "Cache-Control: no-cache, no-store, must-revalidate" \
-H "Pragma: no-cache" \
"${POCKETBASE_URL}/api/collections/releases/records?sort=-created&perPage=1&_=$(date +%s)"); \
file_name=$(echo $latest_release | jq -r '.items[0].file'); \
file_url="${POCKETBASE_URL}/api/files/releases/$(echo $latest_release | jq -r '.items[0].id')/${file_name}"; \
curl -L -H "Cache-Control: no-cache, no-store, must-revalidate" -H "Pragma: no-cache" -o myapp "${file_url}?_=$(date +%s)"; \
chmod +x myapp

# Stage 2: Create the final image
FROM alpine:latest

# Install necessary runtime dependencies
RUN apk add --no-cache ca-certificates bash

# Copy the downloaded binary from the downloader stage
COPY --from=downloader /app/myapp /pb/myapp

# Set the working directory
WORKDIR /pb

# Expose the necessary port
EXPOSE 8080

# Start the application
CMD ["/pb/myapp", "serve", "--http=0.0.0.0:8080"]
is there any way I can prevent docker from caching the downloading step? all so answers say to pass build args. since dokploy can't?
1 Reply
mukhtharcm
mukhtharcmOP8mo ago
Ok. after trying a lot of different options, got it working by adding this line just before downloading step ADD https://www.google.com /app/google.html
Google
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

Did you find this page helpful?