Files
markdownblog/Dockerfile
rattatwinko 682e006e0b docker shit
2025-06-16 22:20:38 +02:00

52 lines
1010 B
Docker

# Build stage
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code and config files
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:18-alpine AS runner
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy necessary files from builder
COPY --from=builder /app/.next ./.next/
COPY --from=builder /app/public ./public/
COPY --from=builder /app/next.config.js ./
# Create a directory for markdown files
RUN mkdir -p /markdown
# Set environment variables
ENV NODE_ENV=production
ENV PORT=8080
ENV HOSTNAME=0.0.0.0
# Expose the port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
# Start the application
CMD ["npm", "start"]