feat: add multi-stage Dockerfile for Astro webapp production deployment
This commit is contained in:
parent
7336efbb4b
commit
8953e0851b
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@ -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"]
|
||||
Loading…
x
Reference in New Issue
Block a user