mirror of
https://github.com/abusoww/tuxmate.git
synced 2026-04-17 15:53:24 +02:00
- Add NEXT_TELEMETRY_DISABLED=1 to Dockerfile (builder and runner stages) - Add NEXT_TELEMETRY_DISABLED=1 to docker-compose.yml - Add build-args to GitHub Actions workflow - Document environment variables in README This ensures no telemetry data is collected from containerized deployments, respecting user privacy and reducing network overhead.
64 lines
1.3 KiB
Docker
64 lines
1.3 KiB
Docker
# Stage 1: Install dependencies
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci --only=production && \
|
|
npm cache clean --force
|
|
|
|
# Stage 2: Build the application
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Disable Next.js telemetry during build
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install all dependencies (including devDependencies)
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build Next.js application
|
|
RUN npm run build
|
|
|
|
# Stage 3: Production runtime
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# Set environment to production
|
|
ENV NODE_ENV=production
|
|
# Disable Next.js telemetry
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files from builder
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Set correct permissions
|
|
RUN chown -R nextjs:nodejs /app
|
|
|
|
# Switch to non-root user
|
|
USER nextjs
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Set environment variable for port
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"]
|