docker
This commit is contained in:
1 parent
5f99b65611
commit
1d78ea599a
4 files changed
+77
-2
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ---- deps: instala dependencias (capa cacheable) ----
|
||||
FROM node:22-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# ---- build: compila Next.js en modo standalone ----
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Variables NEXT_PUBLIC_* se incrustan en el bundle del cliente en build-time,
|
||||
# por eso llegan como build-arg (desde docker-compose) y no solo como env de
|
||||
# runtime del contenedor final.
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ---- runtime: imagen final mínima (next.config.ts tiene output: "standalone") ----
|
||||
FROM node:22-alpine AS runtime
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
||||
USER nextjs
|
||||
|
||||
COPY --from=build --chown=nextjs:nodejs /app/public ./public
|
||||
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["node", "server.js"]
|
||||
Reference in new issue
Block a user