deleted ggogle font and changes in docker config

This commit is contained in:
govardhan
2025-06-18 20:34:48 +05:30
parent 7c50bcc33e
commit 0d8130bc81
3 changed files with 65 additions and 40 deletions

View File

@ -1,50 +1,74 @@
# Use smaller base image
FROM node:18-alpine AS base
# Install dependencies only when needed
# Base image for all stages
FROM node:20-alpine AS base
### Dependencies Stage ###
FROM base AS deps
RUN apk add --no-cache libc6-compat
# Set a fast and reliable Alpine mirror (mirrors.tuna.tsinghua.edu.cn is globally accessible)
# Check if 'git' is needed (only required if package.json has Git-based dependencies)
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.22/main" > /etc/apk/repositories && \
echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.22/community" >> /etc/apk/repositories && \
apk update --verbose && \
apk add --no-cache --verbose libc6-compat git
# Setup pnpm environment
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml* ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile --production=false
# Install dependencies with pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prefer-frozen-lockfile
# Build the source code
### Builder Stage ###
FROM base AS builder
# Enable pnpm
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
WORKDIR /app
# Copy node_modules from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy all source files
COPY . .
# Build the Next.js application
RUN pnpm build
# Optimize build process
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# Build with optimizations
RUN corepack enable pnpm && \
pnpm build && \
pnpm prune --production
# Production image
### Production Runner Stage ###
FROM base AS runner
WORKDIR /app
# Set production environment
ENV NODE_ENV production
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Disable Next.js telemetry
# Learn more: https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Create non-root user and set permissions
RUN addgroup nodejs
RUN adduser -SDH nextjs
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Copy built application
# Copy built artifacts with correct ownership
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
# Switch to non-root user
USER nextjs
# Expose port for the application
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Healthcheck using curl (available in node:20-alpine, unlike wget)
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
CMD ["node", "server.js"]
# Start the Next.js application
CMD ["node", "server.js"]