Files
ember-market-frontend/Dockerfile
2025-03-10 18:30:55 +00:00

55 lines
1.5 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 - these will be overridden by .env.tor when running in Tor mode
ENV NODE_ENV=production
# Use relative URLs for maximum Tor compatibility
ENV NEXT_PUBLIC_API_URL=/api
# Running in Tor mode
ENV NEXT_PUBLIC_TOR_MODE=true
# Use relative URLs for server components - critical for Tor
ENV SERVER_API_URL=/api
# Disable HTTPS for onion services (they're already encrypted)
ENV USE_HTTPS=false
# Set port for internal API calls
ENV INTERNAL_API_PORT=3000
# Disable telemetry
ENV NEXT_TELEMETRY_DISABLED=1
# Start Next.js server
CMD ["npm", "run", "start:tor"]