Skip to content

Commit

Permalink
Docker File upadates
Browse files Browse the repository at this point in the history
  • Loading branch information
Husky-Devel committed Nov 8, 2024
1 parent 4ff2f9f commit e9472f5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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"]

0 comments on commit e9472f5

Please sign in to comment.