From 8953e0851bc63e834133d6ab6951b11415d24751 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 21 May 2025 22:24:31 +0200 Subject: [PATCH] feat: add multi-stage Dockerfile for Astro webapp production deployment --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2bcec4c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Dockerfile for Astro webapp +# Use official Node.js image as the base +FROM node:20-alpine as build + +# Set working directory +WORKDIR /app + +# Copy package files and install dependencies +COPY package.json package-lock.json ./ +RUN npm ci + +# Copy the rest of the application code +COPY . . + +# Build the Astro project +RUN npm run build + +# Production image +FROM node:20-alpine as prod +WORKDIR /app + +# Install only production dependencies +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev + +# Copy built files from build stage +COPY --from=build /app/dist ./dist +COPY public ./public + +# Expose Astro's default port +EXPOSE 4321 + +# Start the Astro preview server +CMD ["npx", "astro", "preview"]