This commit is contained in:
Keven 2025-12-09 16:41:39 -03:00
parent e39970587b
commit 8f9659ea5b

View file

@ -5,11 +5,27 @@ FROM node:20-alpine AS builder
WORKDIR /app WORKDIR /app
# Copia pacotes e instala dependências
COPY package*.json ./ COPY package*.json ./
RUN npm ci RUN npm ci
# Copia o restante do código
COPY . . COPY . .
# ---------- Variáveis de build ----------
# Estas variáveis são usadas pelo Next.js durante o "build"
# para embutir no bundle do frontend.
ARG NEXT_PUBLIC_ORIUS_APP_STATE
ARG NEXT_PUBLIC_ORIUS_APP_API_URL
ARG NEXT_PUBLIC_ORIUS_APP_API_PREFIX
ARG NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE
ENV NEXT_PUBLIC_ORIUS_APP_STATE=$NEXT_PUBLIC_ORIUS_APP_STATE
ENV NEXT_PUBLIC_ORIUS_APP_API_URL=$NEXT_PUBLIC_ORIUS_APP_API_URL
ENV NEXT_PUBLIC_ORIUS_APP_API_PREFIX=$NEXT_PUBLIC_ORIUS_APP_API_PREFIX
ENV NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE=$NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE
# ---------- Build ----------
ENV NODE_ENV=production ENV NODE_ENV=production
RUN npm run build RUN npm run build
@ -20,6 +36,7 @@ FROM node:20-alpine AS runner
WORKDIR /app WORKDIR /app
# ---------- Variáveis em runtime ----------
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
@ -29,7 +46,7 @@ COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./ COPY --from=builder /app/package*.json ./
# Corrige permissões (para cache de imagens, etc.) # ---------- Corrige permissões ----------
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs \ RUN addgroup -S nodejs && adduser -S nextjs -G nodejs \
&& mkdir -p .next/cache/images \ && mkdir -p .next/cache/images \
&& chown -R nextjs:nodejs /app && chown -R nextjs:nodejs /app
@ -38,5 +55,5 @@ USER nextjs
EXPOSE 3000 EXPOSE 3000
# Executa o servidor standalone gerado pelo Next # ---------- Executa o servidor ----------
CMD ["node", "server.js"] CMD ["node", "server.js"]