Files
tm_panel/Dockerfile
T
AmirReza Jamali de0e31bac5 feat(docker): add BACKEND_API_BASE_URL support for build-time routing
- Introduced ARG and ENV for BACKEND_API_BASE_URL in Dockerfile to ensure the correct API base URL is available during the build process.
- Updated next.config.mjs to include a warning about the implications of setting BACKEND_API_BASE_URL in the environment file, emphasizing its impact on multi-domain routing.
2026-06-01 12:55:52 +03:30

36 lines
973 B
Docker

FROM docker-mirror.ravanertebat.ir/hub/node:22.14 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="${PNPM_HOME}:${PATH}"
WORKDIR /app
RUN corepack enable
FROM base AS deps
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
# next.config.mjs evaluates rewrites() at build time, so the optional
# BACKEND_API_BASE_URL override must be available here to be baked into the
# routes manifest. Left unset, the host-based routing (opplens.com vs
# opplenz.com) applies and no env is needed.
ARG BACKEND_API_BASE_URL
ENV BACKEND_API_BASE_URL=${BACKEND_API_BASE_URL}
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm run build
FROM docker-mirror.ravanertebat.ir/hub/node:22.14 AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV HOSTNAME="0.0.0.0"
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]