feat: Implement a frontend entrypoint script for conditional dependency installation and use named volumes for node_modules and .next.
This commit is contained in:
parent
dcedf491df
commit
58106b8dd8
@ -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:
|
||||||
|
|||||||
@ -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
11
frontend/entrypoint.sh
Normal 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 "$@"
|
||||||
Loading…
Reference in New Issue
Block a user