66 lines
1.9 KiB
Docker
66 lines
1.9 KiB
Docker
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies for sharp and libvips with HEIF support
|
|
# See: https://sharp.pixelplumbing.com/install#alpine
|
|
RUN apk add --no-cache \
|
|
build-base \
|
|
pkgconf \
|
|
# libvips runtime dependencies
|
|
libjpeg-turbo-dev \
|
|
libpng-dev \
|
|
libwebp-dev \
|
|
tiff-dev \
|
|
libexif-dev \
|
|
lcms2-dev \
|
|
glib-dev \
|
|
# libvips itself and its HEIF support
|
|
vips-dev \
|
|
libheif-dev \
|
|
# Codecs for HEIF
|
|
libde265-dev \
|
|
x265-dev
|
|
|
|
COPY package*.json ./
|
|
# Tell sharp to use the system-wide libvips we just installed with HEIF support
|
|
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# ---- Runner ----
|
|
FROM node:22-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
# Standalone output
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Sharp native binaries are no longer copied directly,
|
|
# as sharp is built against system libvips and is part of node_modules copied with the standalone app.
|
|
# If sharp is needed outside standalone, node_modules would need to be copied.
|
|
# COPY --from=builder /app/node_modules/sharp ./node_modules/sharp
|
|
# COPY --from=builder /app/node_modules/@img ./node_modules/@img
|
|
|
|
RUN mkdir -p /app/data/uploads/photos /app/data/uploads/videos /app/data/uploads/music \
|
|
&& chown -R nextjs:nodejs /app/data
|
|
|
|
# Entrypoint fixes data dir permissions at runtime (volume mount overrides)
|
|
RUN apk add --no-cache su-exec \
|
|
&& printf '#!/bin/sh\nmkdir -p /app/data/uploads/photos /app/data/uploads/videos /app/data/uploads/music\nchown -R nextjs:nodejs /app/data 2>/dev/null || true\nexec su-exec nextjs node server.js\n' > /app/entrypoint.sh \
|
|
&& chmod +x /app/entrypoint.sh
|
|
|
|
EXPOSE 3000
|
|
CMD ["/app/entrypoint.sh"]
|