From cc8fc50a2b868bbb4d085020e3e347fc4b9f8efb Mon Sep 17 00:00:00 2001 From: Oliver Gwyther Date: Fri, 15 Aug 2025 23:19:10 +0100 Subject: [PATCH] Fix deployment issues: remove volume mounts, run nginx as root, add fallback vite build strategy --- Dockerfile | 18 ++++++++++-------- docker-compose.yml | 12 +++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 144f209..faf7f17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,8 +71,11 @@ RUN printf 'export interface UpdateCollectionData {\n name?: string;\n descrip # 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 +# 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) -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 RUN ls -la /app/dist @@ -92,14 +95,13 @@ COPY nginx.conf /etc/nginx/nginx.conf # Create nginx pid directory RUN mkdir -p /var/run/nginx -# Set proper permissions -RUN chown -R nginx:nginx /usr/share/nginx/html -RUN chown -R nginx:nginx /var/cache/nginx -RUN chown -R nginx:nginx /var/log/nginx -RUN chown -R nginx:nginx /var/run/nginx +# Set proper permissions for nginx directories +RUN chmod -R 755 /usr/share/nginx/html +RUN mkdir -p /var/cache/nginx /var/log/nginx /var/run/nginx +RUN chmod -R 755 /var/cache/nginx /var/log/nginx /var/run/nginx -# Switch to non-root user for security -USER nginx +# Run as root for demo purposes (avoid permission issues) +# USER nginx # Expose port 80 EXPOSE 80 diff --git a/docker-compose.yml b/docker-compose.yml index 4dc90cc..14990ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,9 @@ services: environment: - NODE_ENV=production restart: unless-stopped - volumes: - - scriptshare_logs:/var/log/nginx + # Commented out volumes to avoid permission issues in containerized deployment + # volumes: + # - scriptshare_logs:/var/log/nginx healthcheck: test: ["CMD", "curl", "-f", "http://localhost/health"] interval: 30s @@ -27,6 +28,7 @@ services: - "traefik.http.routers.scriptshare.rule=Host(`scriptshare.localhost`)" - "traefik.http.services.scriptshare.loadbalancer.server.port=80" -volumes: - scriptshare_logs: - driver: local +# Commented out volumes to avoid permission issues +# volumes: +# scriptshare_logs: +# driver: local