docker
This commit is contained in:
1 parent
5f99b65611
commit
1d78ea599a
4 files changed
+77
-2
No files matched your search
@@ -0,0 +1,9 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
.env*.local
|
||||||
|
.env.local
|
||||||
|
.DS_Store
|
||||||
|
npm-debug.log*
|
||||||
|
.claude
|
||||||
|
*.md
|
||||||
+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"]
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Levanta solo el frontend (Next.js). El backend (Internal-API) tiene su
|
||||||
|
# propio docker-compose.yml en ese repositorio.
|
||||||
|
#
|
||||||
|
# NEXT_PUBLIC_API_URL se necesita en BUILD time (Next.js lo incrusta en el
|
||||||
|
# bundle del cliente), así que viene de `build.args`, no solo de `environment`.
|
||||||
|
# Docker Compose solo autocarga un archivo llamado ".env" en este mismo
|
||||||
|
# directorio para resolver los ${...} de este archivo — como aquí usamos
|
||||||
|
# ".env.production", hay que decírselo explícitamente al levantar:
|
||||||
|
#
|
||||||
|
# docker compose --env-file .env.production up -d --build
|
||||||
|
#
|
||||||
|
# (o copia/renombra .env.production a .env si prefieres el comportamiento
|
||||||
|
# por defecto de `docker compose up`).
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:?Define NEXT_PUBLIC_API_URL (en .env.production) con la URL pública del backend}
|
||||||
|
env_file:
|
||||||
|
- .env.production
|
||||||
|
ports:
|
||||||
|
- "${FRONTEND_PORT:-3000}:3000"
|
||||||
|
restart: unless-stopped
|
||||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
import "./.next/dev/types/routes.d.ts";
|
import "./.next/types/routes.d.ts";
|
||||||
import "./.next/dev/types/root-params.d.ts";
|
import "./.next/types/root-params.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
Reference in new issue
Block a user