arcticaurora commited on
Commit
07410e1
·
verified ·
1 Parent(s): e361d07

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -36
Dockerfile CHANGED
@@ -1,49 +1,26 @@
1
  # Build stage
2
- FROM node:20-alpine AS builder
3
 
4
- # Install pnpm
5
  RUN npm install -g pnpm
6
 
7
- # Clone and build AIAW
8
- WORKDIR /build
9
- RUN apk add --no-cache git
10
  RUN git clone https://github.com/NitroRCr/AIaW.git . && \
11
  git checkout -f $(git describe --tags $(git rev-list --tags --max-count=1))
12
 
13
- # Copy environment configuration for Docker build
14
- COPY <<EOF .env.local
15
- # Basic configuration for static build
16
- VITE_APP_VERSION=$(git describe --tags)
17
- EOF
18
-
19
- # Install dependencies and build
20
  RUN pnpm install
21
  RUN pnpm build -m pwa
22
 
23
- # Serve stage
24
- FROM nginx:alpine
25
-
26
- # Copy built files
27
- COPY --from=builder /build/dist/pwa /usr/share/nginx/html
28
-
29
- # Configure nginx to listen on port 7860 (required by HF Spaces)
30
- RUN echo 'server {\n\
31
- listen 7860;\n\
32
- server_name localhost;\n\
33
- root /usr/share/nginx/html;\n\
34
- index index.html;\n\
35
- location / {\n\
36
- try_files $uri $uri/ /index.html;\n\
37
- }\n\
38
- # Handle WebSocket connections if needed\n\
39
- location /ws {\n\
40
- proxy_http_version 1.1;\n\
41
- proxy_set_header Upgrade $http_upgrade;\n\
42
- proxy_set_header Connection "upgrade";\n\
43
- }\n\
44
- }' > /etc/nginx/conf.d/default.conf
45
 
46
  EXPOSE 7860
47
 
48
- # Run nginx in foreground
49
- CMD ["nginx", "-g", "daemon off;"]
 
1
  # Build stage
2
+ FROM node:20 AS builder
3
 
 
4
  RUN npm install -g pnpm
5
 
6
+ WORKDIR /app
7
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
 
8
  RUN git clone https://github.com/NitroRCr/AIaW.git . && \
9
  git checkout -f $(git describe --tags $(git rev-list --tags --max-count=1))
10
 
 
 
 
 
 
 
 
11
  RUN pnpm install
12
  RUN pnpm build -m pwa
13
 
14
+ # Serve stage - using Python for simplicity
15
+ FROM python:3.11-slim
16
+
17
+ RUN useradd -m -u 1000 user
18
+ USER user
19
+ WORKDIR /home/user
20
+
21
+ COPY --from=builder --chown=user:user /app/dist/pwa ./app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  EXPOSE 7860
24
 
25
+ # Serve the PWA
26
+ CMD ["python", "-m", "http.server", "7860", "--directory", "app"]