Fix deployment issues: remove volume mounts, run nginx as root, add fallback vite build strategy

This commit is contained in:
2025-08-15 23:19:10 +01:00
parent 29e99556ab
commit cc8fc50a2b
2 changed files with 17 additions and 13 deletions

View File

@ -71,8 +71,11 @@ RUN printf 'export interface UpdateCollectionData {\n name?: string;\n descrip
# Mock users API with complete interface # Mock users API with complete interface
RUN printf 'export interface UpdateUserData {\n username?: string;\n displayName?: string;\n bio?: string;\n}\nexport const usersApi = {\n getUser: async (id: string) => null,\n getUserById: async (id: string) => null,\n getAllUsers: async () => [],\n searchUsers: async (query: string) => [],\n createUser: async (data: any) => ({ id: "mock" }),\n updateUser: async (id: string, data: UpdateUserData) => ({ id }),\n updateUserPermissions: async (id: string, permissions: any) => ({ id })\n};' > src/lib/api/users.ts RUN printf 'export interface UpdateUserData {\n username?: string;\n displayName?: string;\n bio?: string;\n}\nexport const usersApi = {\n getUser: async (id: string) => null,\n getUserById: async (id: string) => null,\n getAllUsers: async () => [],\n searchUsers: async (query: string) => [],\n createUser: async (data: any) => ({ id: "mock" }),\n updateUser: async (id: string, data: UpdateUserData) => ({ id }),\n updateUserPermissions: async (id: string, permissions: any) => ({ id })\n};' > src/lib/api/users.ts
# Create a custom package.json script that skips TypeScript
RUN echo '{"name":"scriptshare","scripts":{"build-no-ts":"vite build --mode development"}}' > package-build.json
# Skip TypeScript checking and build with Vite only (frontend demo) # Skip TypeScript checking and build with Vite only (frontend demo)
RUN npx vite build --mode development RUN npx vite build --mode development --config vite.config.ts || echo "Direct vite failed, trying alternative..." && npm run build-no-ts
# Verify build output exists # Verify build output exists
RUN ls -la /app/dist RUN ls -la /app/dist
@ -92,14 +95,13 @@ COPY nginx.conf /etc/nginx/nginx.conf
# Create nginx pid directory # Create nginx pid directory
RUN mkdir -p /var/run/nginx RUN mkdir -p /var/run/nginx
# Set proper permissions # Set proper permissions for nginx directories
RUN chown -R nginx:nginx /usr/share/nginx/html RUN chmod -R 755 /usr/share/nginx/html
RUN chown -R nginx:nginx /var/cache/nginx RUN mkdir -p /var/cache/nginx /var/log/nginx /var/run/nginx
RUN chown -R nginx:nginx /var/log/nginx RUN chmod -R 755 /var/cache/nginx /var/log/nginx /var/run/nginx
RUN chown -R nginx:nginx /var/run/nginx
# Switch to non-root user for security # Run as root for demo purposes (avoid permission issues)
USER nginx # USER nginx
# Expose port 80 # Expose port 80
EXPOSE 80 EXPOSE 80

View File

@ -14,8 +14,9 @@ services:
environment: environment:
- NODE_ENV=production - NODE_ENV=production
restart: unless-stopped restart: unless-stopped
volumes: # Commented out volumes to avoid permission issues in containerized deployment
- scriptshare_logs:/var/log/nginx # volumes:
# - scriptshare_logs:/var/log/nginx
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"] test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s interval: 30s
@ -27,6 +28,7 @@ services:
- "traefik.http.routers.scriptshare.rule=Host(`scriptshare.localhost`)" - "traefik.http.routers.scriptshare.rule=Host(`scriptshare.localhost`)"
- "traefik.http.services.scriptshare.loadbalancer.server.port=80" - "traefik.http.services.scriptshare.loadbalancer.server.port=80"
volumes: # Commented out volumes to avoid permission issues
scriptshare_logs: # volumes:
driver: local # scriptshare_logs:
# driver: local