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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -25
Dockerfile CHANGED
@@ -1,13 +1,14 @@
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,44 +25,47 @@ RUN apt-get update && \
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"]
 
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
  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
 
37
+ # Run as root to ensure correct install location
38
+ USER root
39
  RUN npx playwright install --with-deps chromium && \
40
  mkdir -p /home/node/.cache/ms-playwright && \
41
  chmod -R 777 /home/node/.cache/ms-playwright
42
+ USER node
43
 
44
  ###############################################################################
45
+ # 3. Startup script (clone repo at run-time like the second Dockerfile)
46
  ###############################################################################
47
+ COPY <<'EOF' /usr/local/bin/start.sh
48
+ #!/usr/bin/env bash
49
+ set -e
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ echo "Cloning \$REPO …"
52
+ git clone --depth 1 "\$REPO" /tmp/app
53
+ cd /tmp/app
54
+
55
+ # (Optional) if your repo has devDependencies you need at runtime,
56
+ # drop the --omit=dev flag.
57
+ npm install --omit=dev
58
+
59
+ # Ensure the app can write wherever it needs
60
+ chmod -R 777 /tmp/app
61
+
62
+ exec npm start
63
+ EOF
64
+
65
+ RUN chmod +x /usr/local/bin/start.sh
66
 
67
  ###############################################################################
68
+ # 4. Container metadata
69
  ###############################################################################
70
+ EXPOSE 7860
71
  CMD ["/usr/local/bin/start.sh"]