@@ -42,9 +42,10 @@ FROM node:22-alpine AS production
4242
4343WORKDIR /app
4444
45- # Create non-root user for security
45+ # Create non-root user for security and install su-exec for entrypoint
4646RUN addgroup -g 1001 -S nodejs && \
47- adduser -S nodejs -u 1001
47+ adduser -S nodejs -u 1001 && \
48+ apk add --no-cache su-exec
4849
4950# Copy backend package files
5051COPY backend/package.json ./
@@ -62,8 +63,9 @@ COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
6263# Create data directory for SQLite databases
6364RUN mkdir -p /app/data && chown -R nodejs:nodejs /app/data
6465
65- # Switch to non-root user
66- USER nodejs
66+ # Copy entrypoint script
67+ COPY docker-entrypoint.sh /app/docker-entrypoint.sh
68+ RUN chmod +x /app/docker-entrypoint.sh
6769
6870# Expose port
6971EXPOSE 3000
@@ -76,5 +78,6 @@ ENV PORT=3000
7678HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
7779 CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
7880
79- # Start the server
81+ # Start via entrypoint (runs as root to fix permissions, then drops to nodejs)
82+ ENTRYPOINT ["/app/docker-entrypoint.sh" ]
8083CMD ["node" , "dist/index.js" ]
0 commit comments