52 lines
1.4 KiB
Docker
52 lines
1.4 KiB
Docker
# Use official Node.js image as base
|
|
FROM node:18-alpine AS builder
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
|
|
RUN npm install --force
|
|
|
|
COPY . .
|
|
|
|
# Set build-time environment variables to use relative URLs
|
|
ENV NEXT_PUBLIC_API_URL=/api
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Build the Next.js application
|
|
RUN npm run build
|
|
|
|
# ---- Production Stage ----
|
|
FROM node:18-alpine AS runner
|
|
|
|
# Set working directory inside the container
|
|
WORKDIR /app
|
|
|
|
RUN mkdir -p /app/public
|
|
|
|
# Copy only necessary files from builder
|
|
COPY --from=builder /app/package.json /app/package-lock.json ./
|
|
COPY --from=builder /app/.next ./.next
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/server.js ./
|
|
COPY --from=builder /app/.env.tor ./
|
|
COPY --from=builder /app/.env.backend ./
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# If you have a backend folder, copy it as well
|
|
COPY --from=builder /app/backend ./backend
|
|
|
|
EXPOSE 3000
|
|
|
|
# Set runtime environment variables
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_PUBLIC_API_URL=/api
|
|
# Force server to use internal URLs (no localhost references)
|
|
ENV SERVER_API_URL=http://localhost:3000/api
|
|
# Disable HTTPS for internal container communication
|
|
ENV USE_HTTPS=false
|
|
# Ensure internal API calls for server components go to the right port
|
|
ENV INTERNAL_API_PORT=3000
|
|
# Disable telemetry
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Start Next.js server
|
|
CMD ["npm", "run", "start:tor"] |