Files
365devnet/Dockerfile
Richard Bergsma 67d976ac0f Refactor Docker setup for Astro SSR application and Nginx reverse proxy
- Updated docker-compose.yml to define services for the Astro SSR application and Nginx reverse proxy, including health checks and environment variables.
- Modified Dockerfile to implement a multi-stage build process, optimizing dependency installation and production setup.
- Enhanced nginx.conf with improved proxy settings, security headers, and caching strategies for static assets, ensuring better performance and security.
2025-11-05 00:07:35 +01:00

41 lines
907 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/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"]