build: package persistent deployment and maintenance commands

This commit is contained in:
2026-09-15 21:48:12 +03:30
parent 9319c05710
commit ee9f49e4b7
7 changed files with 59 additions and 12 deletions

View File

@@ -4,6 +4,9 @@ FROM node:22-alpine AS dependencies
WORKDIR /app
# npm may build the native SQLite binding when no matching prebuild is available.
RUN apk add --no-cache python3 make g++
ARG NPM_REGISTRY=https://package-mirror.liara.ir/repository/npm/
ENV NEXT_TELEMETRY_DISABLED=1
@@ -29,7 +32,8 @@ WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
HOSTNAME=0.0.0.0 \
PORT=3000
PORT=3000 \
DATA_DIR=/data
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
@@ -37,12 +41,12 @@ RUN addgroup --system --gid 1001 nodejs \
COPY --from=verification --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=verification --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=verification --chown=nextjs:nodejs /app/public ./public
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next/cache
RUN mkdir -p .next/cache /data && chown -R nextjs:nodejs .next/cache /data
USER nextjs
EXPOSE 3000
HEALTHCHECK --interval=2s --timeout=2s --start-period=3s --retries=30 \
CMD ["node", "-e", "fetch('http://127.0.0.1:3000/').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
CMD ["node", "-e", "fetch('http://127.0.0.1:3000/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
CMD ["node", "server.js"]