Skip to content

Commit d15063b

Browse files
committed
Use multi-stage builds to keep the image smaller. Clean up unnecessary files after install to reduce image size.
1 parent 1945817 commit d15063b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Dockerfile.playwright

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ RUN apt-get update && apt-get install -y wget gnupg2 && \
88
apt-get update && apt-get install -y temurin-11-jdk && \
99
rm -rf /var/lib/apt/lists/*
1010

11-
# Install Allure CLI globally
12-
RUN npm install -g allure-commandline --force
13-
14-
# Set JAVA_HOME for Allure
15-
ENV JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64
16-
ENV PATH=$JAVA_HOME/bin:$PATH
17-
1811
WORKDIR /app
1912

2013
# Copy only package files first to cache layer
@@ -32,10 +25,15 @@ COPY . .
3225
# ---- Final Stage ----
3326
FROM mcr.microsoft.com/playwright:v1.53.1-jammy
3427

35-
# Copy Java and Allure from build stage
36-
COPY --from=build /usr/lib/jvm/ /usr/lib/jvm/
37-
COPY --from=build /usr/local/lib/node_modules/allure-commandline /usr/local/lib/node_modules/allure-commandline
38-
RUN ln -s /usr/local/lib/node_modules/allure-commandline/bin/allure /usr/local/bin/allure
28+
# Install Java 11 (required for Allure) in the final image
29+
RUN apt-get update && apt-get install -y wget gnupg2 && \
30+
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor -o /usr/share/keyrings/adoptium.gpg && \
31+
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb focal main" | tee /etc/apt/sources.list.d/adoptium.list && \
32+
apt-get update && apt-get install -y temurin-11-jdk && \
33+
rm -rf /var/lib/apt/lists/*
34+
35+
# Install Allure CLI globally in the final image
36+
RUN npm install -g allure-commandline --force
3937

4038
ENV JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64
4139
ENV PATH=$JAVA_HOME/bin:$PATH

0 commit comments

Comments
 (0)