docker shit
This commit is contained in:
47
Dockerfile
47
Dockerfile
@@ -1,23 +1,52 @@
|
||||
# Use Node.js as the base image
|
||||
FROM node:18
|
||||
# Build stage
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
# Set the working directory
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json (if available)
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of the application code
|
||||
# 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
|
||||
|
||||
# Expose the port your app runs on
|
||||
EXPOSE 3000
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=8080
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
# Command to run the application
|
||||
# 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"]
|
||||
Reference in New Issue
Block a user