Ctrl K
ComunidadGuías…

Dockerfile.core

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# syntax=docker/dockerfile:1.7

# Use Alpine base image for smaller size
FROM node:26-alpine AS builder
ENV PNPM_HOME=/pnpm
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g pnpm@12.3.2

RUN apk add --no-cache python3 make g++ postgresql-dev

WORKDIR /workspace

COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
COPY be/apps/core/package.json be/apps/core/package.json
COPY be/apps/dashboard/package.json be/apps/dashboard/package.json
COPY apps/web/package.json apps/web/package.json
COPY patches/ ./patches/

RUN pnpm fetch --filter core...
RUN pnpm fetch --filter '@afilmory/web...'
RUN pnpm fetch --filter '@afilmory/dashboard...'

COPY . .

RUN pnpm install --filter core... --filter '@afilmory/web...' --filter '@afilmory/dashboard...' --frozen-lockfile
RUN pnpm --filter @afilmory/web build:serve \
  && pnpm --filter @afilmory/dashboard build:prod:saas \
  && pnpm --filter core build
RUN mkdir -p be/apps/core/dist/static/web && cp -r apps/web/dist/* be/apps/core/dist/static/web/
RUN mkdir -p be/apps/core/dist/static/dashboard && cp -r be/apps/dashboard/dist/* be/apps/core/dist/static/dashboard/

FROM node:26-alpine AS runner
ENV NODE_ENV=production
WORKDIR /app

# Runtime deps for image processing:
# - perl: required by exiftool-vendored on Linux
# - perl-image-exiftool: provides the exiftool binary
# - vips: runtime library for sharp
# - libheif: enable HEIF/HEIC support in libvips when available
# Build deps for native modules (pg-native/libpq):
# - python3, make, g++: required to build native Node.js modules
# - postgresql-dev: provides libpq headers and runtime library for pg-native
# - postgresql-libs: runtime library for libpq (kept after build)
RUN apk add --no-cache \
  curl \
  perl \
  exiftool \
  perl-image-exiftool \
  vips \
  libheif \
  libc6-compat \
  gcompat \
  postgresql-libs \
  && apk add --no-cache --virtual .build-deps \
  python3 \
  make \
  g++ \
  postgresql-dev \
  && EXIFTOOL_BIN="$(command -v exiftool)" \
  && echo "Using exiftool binary at ${EXIFTOOL_BIN}" \
  && "${EXIFTOOL_BIN}" -ver \
  && ln -sf "${EXIFTOOL_BIN}" /usr/local/bin/exiftool
ENV EXIFTOOL_PATH=/usr/local/bin/exiftool
COPY --from=builder /workspace/be/apps/core/dist ./dist
COPY --from=builder /workspace/be/packages/db/migrations ./migrations
COPY --from=builder /workspace/be/apps/core/docker-entrypoint.sh ./docker-entrypoint.sh
COPY --from=builder /workspace/patches/ ./patches/


RUN chmod +x ./docker-entrypoint.sh

RUN if [ -f dist/package.json ]; then \
  cd dist && \
  npm install --omit=dev --no-audit --no-fund; \
  fi

# Remove build tools after native modules are built to reduce image size
RUN apk del .build-deps

EXPOSE 1841

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "./dist/main.js"]