Update Dockerfile
Browse files- Dockerfile +27 -25
Dockerfile
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
FROM node:24-bullseye-slim
|
| 2 |
|
| 3 |
###############################################################################
|
| 4 |
-
# 1. Install
|
| 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 |
-
#
|
| 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
|
| 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.
|
| 41 |
###############################################################################
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
exec npm start
|
| 58 |
-
start.sh
|
| 59 |
-
RUN chmod +x /usr/local/bin/start.sh
|
| 60 |
|
| 61 |
###############################################################################
|
| 62 |
-
# 4.
|
| 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"]
|