docker/local: add production-prebuilt stage and use it in docker-compose.yml

This commit is contained in:
2025-10-06 17:38:25 +02:00
parent d7874ef9de
commit 30cfe78c59
2 changed files with 29 additions and 1 deletions

View File

@@ -63,3 +63,29 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
# Start the application with startup script # Start the application with startup script
CMD ["/app/start.sh"] CMD ["/app/start.sh"]
# Prebuilt runtime stage (used locally): copies prebuilt dist and server-dist from context
FROM node:22-alpine AS production-prebuilt
RUN npm install -g pnpm ts-node && apk add --no-cache su-exec curl
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile --prod
# Copy prebuilt artifacts from repository
COPY dist ./dist
COPY server-dist ./server-dist
COPY public ./public
COPY start.sh ./start.sh
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001 \
&& chmod +x /app/start.sh \
&& chown -R nextjs:nodejs /app \
&& chown root:root /app/.storage 2>/dev/null || true
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" || exit 1
CMD ["/app/start.sh"]

View File

@@ -1,6 +1,8 @@
services: services:
stargirlnails: stargirlnails:
build: . build:
context: .
target: production-prebuilt
ports: ports:
- "3000:3000" - "3000:3000"
env_file: env_file: