diff --git a/Dockerfile b/Dockerfile index ecbe24b..3e5f67e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM node:20.11-slim AS builder WORKDIR /app ENV PUPPETEER_SKIP_DOWNLOAD=TRUE + # Install any needed system dependencies for the build RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -18,28 +19,24 @@ COPY . . RUN mv astro.config.mjs.docker astro.config.mjs && \ yarn build -# Runtime stage - using Node since it's a SSR Astro app +# Runtime stage FROM node:20.11-slim AS runtime WORKDIR /app ENV HOST=0.0.0.0 \ PORT=4321 \ NODE_ENV=production -# Copy only what's needed to run the app +# Copy build artifacts and dependencies COPY --from=builder /app/dist ./dist +COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/yarn.lock ./yarn.lock -# Install only production dependencies -RUN yarn install --frozen-lockfile --production=true && \ - # Create non-root user - addgroup --system --gid 1001 nodejs && \ +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ adduser --system --uid 1001 nodejs && \ - # Clean up - yarn cache clean && \ chown -R nodejs:nodejs /app USER nodejs -EXPOSE 4321 +EXPOSE 4321 CMD ["node", "./dist/server/entry.mjs"] \ No newline at end of file