Fix: Use startup script to create .storage directories at runtime

- Changed from bind mount to named volume for .storage
- Added start.sh script that creates required directories before starting the app
- This prevents ENOENT errors when initializing admin user
This commit is contained in:
2025-10-01 23:05:21 +02:00
parent 713da5a802
commit 857b60e1f5
3 changed files with 20 additions and 7 deletions

View File

@@ -44,14 +44,15 @@ COPY --from=base /app/src/server/routes ./src/server/routes
COPY --from=base /app/src/server/rpc ./src/server/rpc
COPY --from=base /app/src/server/lib ./src/server/lib
COPY --from=base /app/tsconfig.server.json ./tsconfig.server.json
# Create .storage directory and subdirectories
RUN mkdir -p /app/.storage/users /app/.storage/bookings /app/.storage/treatments /app/.storage/availability /app/.storage/cancellation-tokens
COPY start.sh ./start.sh
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# Make start script executable
RUN chmod +x /app/start.sh
# Change ownership of the app directory
RUN chown -R nextjs:nodejs /app
USER nextjs
@@ -63,6 +64,5 @@ 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
# Start the application with ts-node and dedicated tsconfig for NodeNext
# Start the precompiled server JS (kein ts-node im Runtime)
CMD ["node", "server-dist/index.js"]
# Start the application with startup script
CMD ["/app/start.sh"]