Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +10 -11
Dockerfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
FROM node:20
|
2 |
|
3 |
-
# Create
|
4 |
RUN groupadd -r appuser && useradd -m -r -g appuser appuser
|
5 |
|
6 |
# Set working directory
|
@@ -10,21 +10,20 @@ WORKDIR /usr/src/app
|
|
10 |
COPY package*.json ./
|
11 |
RUN npm install
|
12 |
|
13 |
-
#
|
14 |
-
USER appuser
|
15 |
-
|
16 |
-
# Set environment variable for Playwright browser path
|
17 |
ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
|
18 |
|
19 |
-
# Install Playwright browsers and
|
20 |
RUN npx playwright install --with-deps && \
|
21 |
-
mkdir -p /home/appuser/.cache/ms-playwright
|
|
|
22 |
|
23 |
-
# Copy application
|
24 |
COPY . .
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
|
29 |
-
#
|
|
|
30 |
CMD ["node", "server.js"]
|
|
|
1 |
FROM node:20
|
2 |
|
3 |
+
# Create non-root user with a home directory
|
4 |
RUN groupadd -r appuser && useradd -m -r -g appuser appuser
|
5 |
|
6 |
# Set working directory
|
|
|
10 |
COPY package*.json ./
|
11 |
RUN npm install
|
12 |
|
13 |
+
# Set environment variable so Playwright installs browsers in a directory we'll later assign to appuser
|
|
|
|
|
|
|
14 |
ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
|
15 |
|
16 |
+
# Install Playwright browsers and dependencies as root
|
17 |
RUN npx playwright install --with-deps && \
|
18 |
+
mkdir -p /home/appuser/.cache/ms-playwright && \
|
19 |
+
chown -R appuser:appuser /home/appuser/.cache/ms-playwright /usr/src/app
|
20 |
|
21 |
+
# Copy the rest of the application code
|
22 |
COPY . .
|
23 |
|
24 |
+
# Switch to the non-root user
|
25 |
+
USER appuser
|
26 |
|
27 |
+
# Expose the desired port and start the server
|
28 |
+
EXPOSE 7860
|
29 |
CMD ["node", "server.js"]
|