Files
365devnet/Dockerfile
Richard Bergsma 6cd45c254b Update Dockerfile to include template files in the build process
- Added a line to copy template files from the build stage to the final image, ensuring that necessary templates are available in the application directory.
2025-11-07 12:24:39 +01:00

42 lines
960 B
Docker

# Multi-stage build for Astro SSR application
FROM node:lts AS base
WORKDIR /app
# Install dependencies
FROM base AS deps
COPY package*.json ./
RUN npm ci --only=production
# Build stage
FROM base AS build
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production stage
FROM node:lts-alpine AS production
WORKDIR /app
# Copy necessary files
COPY --from=deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
COPY --from=build /app/src/templates ./src/templates
COPY --from=build /app/server.js ./server.js
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/.env ./.env
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s \
CMD node -e "require('http').get('http://localhost:3000/', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
# Start server
CMD ["node", "server.js"]