1
1
# Use an official Node runtime as a parent image
2
- FROM node:14
2
+ FROM node:16
3
3
4
4
# Set the working directory in the container
5
5
WORKDIR /usr/src/app
6
6
7
- # Copy the current directory contents into the container at /usr/src/app
8
- COPY . .
7
+ # Install Chrome to run tests in a headless browser. Adjust these commands if you're using a different browser.
8
+ RUN apt-get update && apt-get install -y wget gnupg \
9
+ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
10
+ && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' \
11
+ && apt-get update \
12
+ && apt-get install -y google-chrome-stable
13
+
14
+ # Optionally, install ChromeDriver if required by your tests.
15
+ # Make sure to match ChromeDriver version with the installed Chrome version.
16
+ # This is a basic example; you might need to adjust versions and paths.
17
+ RUN wget -N http://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip -P ~/ \
18
+ && unzip ~/chromedriver_linux64.zip -d ~/ \
19
+ && rm ~/chromedriver_linux64.zip \
20
+ && mv -f ~/chromedriver /usr/local/share/ \
21
+ && chmod +x /usr/local/share/chromedriver \
22
+ && ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver \
23
+ && ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
24
+
25
+ # Copy the package.json (and possibly package-lock.json or pnpm-lock.yaml) into the container
26
+ COPY package.json pnpm-lock.yaml ./
9
27
10
- # Install any needed packages specified in package.json
11
- RUN npm install
28
+ # Install pnpm globally
29
+ RUN npm install -g pnpm
30
+
31
+ # Install project dependencies
32
+ RUN pnpm install
33
+
34
+ # Copy your project's source code into the container
35
+ COPY . .
12
36
13
- # Install Chrome for Selenium tests
14
- RUN apt-get update && apt-get install -y \
15
- gnupg \
16
- wget \
17
- && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
18
- && apt install ./google-chrome-stable_current_amd64.deb -y
37
+ # Build the project - this compiles your TypeScript files
38
+ RUN pnpm run build
19
39
20
- # Make port available to the world outside this container
40
+ # Make port 8080 available to the world outside this container
21
41
EXPOSE 8080
22
42
23
- # Define environment variable
24
- ENV NODE_ENV production
43
+ # Define environment variable for headless testing and other environment configurations
44
+ ENV NODE_ENV=production \
45
+ CHROME_BIN=/usr/bin/google-chrome \
46
+ HEADLESS=true
25
47
26
- # Run npm test when the container launches
27
- CMD ["npm ", "test "]
48
+ # Command to run when the container starts. This runs your regression tests.
49
+ CMD ["pnpm ", "run", "regression "]
0 commit comments