feat: Implement a frontend entrypoint script for conditional dependency installation and use named volumes for node_modules and .next.

This commit is contained in:
n.tolstov 2025-11-30 22:07:20 +03:00
parent dcedf491df
commit 58106b8dd8
3 changed files with 21 additions and 2 deletions

View File

@ -64,8 +64,8 @@ services:
- NEXT_PUBLIC_WS_URL=ws://192.168.50.130:8091 - NEXT_PUBLIC_WS_URL=ws://192.168.50.130:8091
volumes: volumes:
- ./frontend:/app - ./frontend:/app
- /app/node_modules - frontend_node_modules:/app/node_modules
- /app/.next - frontend_next:/app/.next
ports: ports:
- "3091:3000" - "3091:3000"
depends_on: depends_on:
@ -75,3 +75,5 @@ services:
volumes: volumes:
postgres_data: postgres_data:
piston_packages: piston_packages:
frontend_node_modules:
frontend_next:

View File

@ -11,8 +11,14 @@ RUN npm install
# Copy application code # Copy application code
COPY . . COPY . .
# Make entrypoint executable
RUN chmod +x /app/entrypoint.sh
# Expose port # Expose port
EXPOSE 3000 EXPOSE 3000
# Use entrypoint for dependency sync
ENTRYPOINT ["/app/entrypoint.sh"]
# Run the development server # Run the development server
CMD ["npm", "run", "dev"] CMD ["npm", "run", "dev"]

11
frontend/entrypoint.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
# Sync node_modules if package.json changed
if [ ! -d "node_modules" ] || [ "package.json" -nt "node_modules" ]; then
echo "Installing dependencies..."
npm install
touch node_modules
fi
exec "$@"