restore: working Dockerfile from previous deploy
This commit is contained in:
parent
ff4cdffa09
commit
1b25f0baa4
1 changed files with 72 additions and 5 deletions
77
Dockerfile
77
Dockerfile
|
|
@ -1,6 +1,73 @@
|
||||||
FROM mirror.gcr.io/library/golang:1.23-alpine
|
# =============================================================================
|
||||||
|
# GoHorse Jobs Frontend - Ultra-Optimized Dockerfile
|
||||||
|
# =============================================================================
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Stage 1: Base with pnpm
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
FROM mirror.gcr.io/library/node:20-alpine AS base
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Stage 2: Dependencies
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
FROM base AS deps
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY package.json package-lock.json* pnpm-lock.yaml* ./
|
||||||
RUN echo '--- LS ROOT ---' && ls -la && echo '--- LS BACKEND ---' && ls -la backend
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||||
RUN cd backend && go mod download && CGO_ENABLED=0 GOOS=linux go build -ldflags=" -s -w\ -o ../main .
|
pnpm import 2>/dev/null || true && \
|
||||||
CMD [\.\/main\]
|
pnpm install --frozen-lockfile || pnpm install
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Stage 3: Builder (AQUI ESTAVA O PROBLEMA)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
FROM base AS builder
|
||||||
|
ENV NODE_OPTIONS="--max-old-space-size=512"
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
|
||||||
|
# CORREÇÃO: Copiando TODAS as configs e pastas necessárias
|
||||||
|
COPY package.json next.config.* tsconfig.json postcss.config.mjs ./
|
||||||
|
# Se tiver outras configs como tailwind.config.ts, adicione aqui ou use COPY . . (com dockerignore bom)
|
||||||
|
COPY public ./public
|
||||||
|
COPY src ./src
|
||||||
|
# Adicionei a pasta messages que apareceu no seu ls
|
||||||
|
COPY messages ./messages
|
||||||
|
|
||||||
|
# Build arguments
|
||||||
|
ARG NEXT_PUBLIC_API_URL=http://localhost:8521
|
||||||
|
ARG NEXT_PUBLIC_BACKOFFICE_URL=http://localhost:3001
|
||||||
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||||
|
ENV NEXT_PUBLIC_BACKOFFICE_URL=$NEXT_PUBLIC_BACKOFFICE_URL
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
RUN pnpm build && \
|
||||||
|
rm -rf node_modules/.cache .next/cache
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Stage 4: Production Runner
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
FROM mirror.gcr.io/library/node:20-alpine AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN addgroup -g 1001 -S nodejs && \
|
||||||
|
adduser -u 1001 -S nextjs -G nodejs
|
||||||
|
|
||||||
|
ENV NODE_ENV=production \
|
||||||
|
NEXT_TELEMETRY_DISABLED=1 \
|
||||||
|
PORT=3000 \
|
||||||
|
HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
# O Docker faz o "cp" que você fez na mão AQUI:
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
Loading…
Reference in a new issue