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:
12
Dockerfile
12
Dockerfile
@@ -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"]
|
||||
|
@@ -12,7 +12,7 @@ services:
|
||||
- NODE_ENV=production
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./.storage:/app/.storage
|
||||
- storage-data:/app/.storage
|
||||
networks:
|
||||
- stargirlnails-network
|
||||
healthcheck:
|
||||
@@ -56,6 +56,8 @@ services:
|
||||
|
||||
# Volumes für persistente Daten
|
||||
volumes:
|
||||
storage-data:
|
||||
driver: local
|
||||
certbot-certs:
|
||||
driver: local
|
||||
certbot-webroot:
|
||||
|
11
start.sh
Normal file
11
start.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Create .storage directories if they don't exist
|
||||
mkdir -p /app/.storage/users
|
||||
mkdir -p /app/.storage/bookings
|
||||
mkdir -p /app/.storage/treatments
|
||||
mkdir -p /app/.storage/availability
|
||||
mkdir -p /app/.storage/cancellation-tokens
|
||||
|
||||
# Start the application
|
||||
exec node server-dist/index.js
|
Reference in New Issue
Block a user