api-ix commited on
Commit
13da6cd
·
verified ·
1 Parent(s): 05412ff

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -25
Dockerfile CHANGED
@@ -1,14 +1,13 @@
1
  FROM node:24-bullseye-slim
2
 
3
  ###############################################################################
4
- # 1. Install everything we need in one layer
5
  ###############################################################################
6
  RUN apt-get update && \
7
  apt-get install -y --no-install-recommends \
8
- # Basic tools
9
  git ca-certificates python3 python3-pip build-essential make \
10
  wget curl unzip \
11
- # Chrome/Playwright deps copied from the first Dockerfile
12
  fonts-liberation \
13
  libasound2 \
14
  libatk-bridge2.0-0 \
@@ -25,41 +24,44 @@ RUN apt-get update && \
25
  xdg-utils \
26
  libu2f-udev \
27
  libvulkan1 \
28
- # Virtual display for headless Chrome
29
  xvfb \
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
  ###############################################################################
33
- # 2. Install Playwright and browsers globally (kept for future use)
34
  ###############################################################################
35
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright
 
36
  RUN npx playwright install --with-deps chromium && \
 
37
  chmod -R 777 /home/node/.cache/ms-playwright
38
 
39
  ###############################################################################
40
- # 3. Startup script (clone repo at run-time like the second Dockerfile)
41
  ###############################################################################
42
- COPY <<'start.sh' /usr/local/bin/start.sh
43
- #!/usr/bin/env bash
44
- set -e
45
-
46
- echo "Cloning $REPO"
47
- git clone --depth 1 "$REPO" /tmp/app
48
- cd /tmp/app
49
-
50
- # (Optional) if your repo has devDependencies you need at runtime,
51
- # drop the --omit=dev flag.
52
- npm install --omit=dev
53
-
54
- # Ensure the app can write wherever it needs
55
- chmod -R 777 /tmp/app
56
-
57
- exec npm start
58
- start.sh
59
- RUN chmod +x /usr/local/bin/start.sh
60
 
61
  ###############################################################################
62
- # 4. Container metadata
63
  ###############################################################################
 
64
  EXPOSE 7860
 
 
 
 
65
  CMD ["/usr/local/bin/start.sh"]
 
1
  FROM node:24-bullseye-slim
2
 
3
  ###############################################################################
4
+ # 1. Install system dependencies
5
  ###############################################################################
6
  RUN apt-get update && \
7
  apt-get install -y --no-install-recommends \
 
8
  git ca-certificates python3 python3-pip build-essential make \
9
  wget curl unzip \
10
+ # Playwright / Chromium dependencies
11
  fonts-liberation \
12
  libasound2 \
13
  libatk-bridge2.0-0 \
 
24
  xdg-utils \
25
  libu2f-udev \
26
  libvulkan1 \
 
27
  xvfb \
28
  && rm -rf /var/lib/apt/lists/*
29
 
30
  ###############################################################################
31
+ # 2. Install Playwright (Chromium only)
32
  ###############################################################################
33
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright
34
+
35
  RUN npx playwright install --with-deps chromium && \
36
+ mkdir -p /home/node/.cache/ms-playwright && \
37
  chmod -R 777 /home/node/.cache/ms-playwright
38
 
39
  ###############################################################################
40
+ # 3. Embedded startup script
41
  ###############################################################################
42
+ RUN echo '#!/usr/bin/env bash\n\
43
+ set -e\n\
44
+ \n\
45
+ echo \"📦 Cloning $REPO ...\"\n\
46
+ git clone --depth 1 \"$REPO\" /tmp/app\n\
47
+ cd /tmp/app\n\
48
+ \n\
49
+ echo \"📥 Installing dependencies...\"\n\
50
+ npm install --omit=dev\n\
51
+ \n\
52
+ chmod -R 777 /tmp/app\n\
53
+ \n\
54
+ echo \"🚀 Starting application...\"\n\
55
+ exec npm start\n' > /usr/local/bin/start.sh && \
56
+ chmod +x /usr/local/bin/start.sh
 
 
 
57
 
58
  ###############################################################################
59
+ # 4. Use non-root user and expose port
60
  ###############################################################################
61
+ USER node
62
  EXPOSE 7860
63
+
64
+ ###############################################################################
65
+ # 5. Run app
66
+ ###############################################################################
67
  CMD ["/usr/local/bin/start.sh"]