From 77ba5d05fc75369cdd445c802fa6326d099aa33f Mon Sep 17 00:00:00 2001 From: GeorgeWebberley Date: Thu, 29 Jan 2026 07:45:53 +0100 Subject: [PATCH] Attempt 3 at fixing dockerfile --- Worker.Dockerfile | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Worker.Dockerfile b/Worker.Dockerfile index 86344b4..aefe4c4 100644 --- a/Worker.Dockerfile +++ b/Worker.Dockerfile @@ -1,17 +1,25 @@ -FROM --platform=linux/amd64 node:20-bookworm-slim AS builder -WORKDIR /app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npx tsc --project tsconfig.json +# Use a build argument for the platform to satisfy the warning +ARG TARGETPLATFORM=linux/amd64 +FROM --platform=${TARGETPLATFORM} node:20-bookworm-slim -FROM --platform=linux/amd64 node:20-bookworm-slim WORKDIR /app ENV NODE_ENV=production + +# 1. Copy only the dependency files first (better caching) COPY package*.json ./ -RUN npm install --omit=dev -COPY --from=builder /app/dist ./dist -COPY --from=builder /app/config ./config + +# 2. Install only production dependencies +# This keeps the image small +RUN npm install --omit=dev && npm install -g tsx + +# 3. Copy only the folders the worker actually needs +# This avoids copying the massive .next or .git folders +COPY scripts ./scripts +COPY lib ./lib +COPY config ./config + +# 4. Create data directory RUN mkdir -p /app/data -CMD ["node", "dist/scripts/update-space.js"] \ No newline at end of file +# 5. Run using tsx (already installed) +CMD ["tsx", "scripts/update-space.ts"] \ No newline at end of file