File size: 1,219 Bytes
5cdedc2
7e0bd83
15b6840
2b9a274
5cdedc2
c2ff1d8
26b8420
5cdedc2
 
15b6840
26b8420
 
 
15b6840
7e0bd83
 
 
 
5cdedc2
7e0bd83
 
 
 
 
 
 
 
 
15b6840
5cdedc2
 
7e0bd83
 
 
 
15b6840
7e0bd83
 
 
15b6840
 
7e0bd83
15b6840
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM node:18-slim

# Install dependencies needed for Playwright
RUN apt-get update && \
    apt-get install -y wget gnupg ca-certificates git \
    libnss3 libcups2 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libasound2 fonts-freefont-ttf \
    libglib2.0-0 libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libxfixes3 libxkbcommon0 libpango-1.0-0 libcairo2 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN npx playwright install --with-deps


# Switch to the node user
USER node

# Set environment variables for the user
ENV HOME=/home/node \
    PATH=/home/node/.local/bin:$PATH

# Set the working directory
WORKDIR $HOME/app

# Copy the package.json and package-lock.json files to the working directory
COPY --chown=node:node package*.json ./

# Install Node.js dependencies
RUN npm install

# Install Playwright without needing additional system dependencies
RUN npx playwright install

# Copy the application code to the working directory
COPY --chown=node:node . .

# Ensure the ownership of the directory to the node user
RUN chown -R node:node .

# Expose the port the app runs on
EXPOSE 3000

# Command to run the Node.js server
CMD ["node", "index.js"]