Skip to content

Commit 69845e1

Browse files
committed
A place to start
1 parent 9c04349 commit 69845e1

File tree

6 files changed

+230
-0
lines changed

6 files changed

+230
-0
lines changed

.github/funding.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [ serenity-js ]

.github/workflows/main.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
types: [ opened, synchronize ]
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
jobs:
15+
build-test-publish:
16+
name: "Build -> Test -> Publish"
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v5
21+
22+
- name: Set up Docker BuildX
23+
uses: docker/setup-buildx-action@v3.11.1
24+
25+
- name: Log in to GitHub Container Registry
26+
uses: docker/login-action@v3.6.0
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract Playwright version
33+
id: playwright_version
34+
run: |
35+
version=$(node -p "require('./playwright-installer/package.json').dependencies['@playwright/test']")
36+
echo "version=$version" >> $GITHUB_OUTPUT
37+
38+
- name: Get Ubuntu distro codename from Dockerfile
39+
id: distro
40+
run: |
41+
from_line=$(grep '^FROM' Dockerfile)
42+
# Extract the tag part after 'ubuntu:' and before '@' or end of line
43+
distro=$(echo "$from_line" | sed -n 's/^FROM ubuntu:\([^@]*\).*/\1/p')
44+
# Fallback to default if not found
45+
distro=${distro:-noble}
46+
echo "distro=$distro" >> $GITHUB_OUTPUT
47+
48+
- name: Set image tag
49+
id: tag
50+
run: |
51+
tag="v${{ steps.playwright_version.outputs.version }}-${{ steps.distro.outputs.distro }}"
52+
echo "tag=$tag" >> $GITHUB_OUTPUT
53+
54+
- name: Build image
55+
id: build
56+
uses: docker/build-push-action@v4
57+
with:
58+
context: .
59+
push: false
60+
tags: serenity-js:latest
61+
62+
- name: Test image
63+
run: |
64+
docker run --rm serenity-js:latest whoami
65+
docker run --rm serenity-js:latest node --version
66+
docker run --rm serenity-js:latest java --version
67+
docker run --rm serenity-js:latest google-chrome --version
68+
docker run --rm serenity-js:latest microsoft-edge --version

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
3+
# Playwright Installer
4+
playwright-installer/node_modules/

Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM ubuntu:noble@sha256:728785b59223d755e3e5c5af178fab1be7031f3522c5ccd7a0b32b80d8248123
2+
3+
ARG USERNAME=serenity-js
4+
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
ARG TZ=UTC
7+
8+
ENV LANG=C.UTF-8
9+
ENV LC_ALL=C.UTF-8
10+
11+
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright
12+
13+
## OS Layer
14+
15+
RUN \
16+
apt-get -y update && \
17+
apt-get -y upgrade && \
18+
### Install certificate tools
19+
apt-get install -y ca-certificates curl gpg libnss3-tools p11-kit && \
20+
update-ca-certificates && \
21+
### Update sources
22+
mkdir -p /etc/apt/keyrings && \
23+
curl -sL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
24+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" >> /etc/apt/sources.list.d/nodesource.list && \
25+
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg && \
26+
echo "deb [signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge.list && \
27+
curl -sL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg && \
28+
echo "deb [signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
29+
apt-get -y update && \
30+
### Install Node.js
31+
apt-get install -y default-jre google-chrome-stable microsoft-edge-stable nodejs && \
32+
### Feature-parity with node.js base images.
33+
apt-get install -y --no-install-recommends git openssh-client && \
34+
### Clean up
35+
apt-get clean && \
36+
rm -rf /var/lib/apt/lists/*;
37+
38+
## Application Layer
39+
40+
COPY playwright-installer /tmp/playwright-installer/
41+
42+
RUN \
43+
### Install Playwright
44+
mkdir "$PLAYWRIGHT_BROWSERS_PATH" && \
45+
cd /tmp/playwright-installer/ && \
46+
npm ci && \
47+
npm exec --no -- playwright install --with-deps && \
48+
cd - && \
49+
chmod -R 755 "$PLAYWRIGHT_BROWSERS_PATH" && \
50+
### Clean up
51+
rm -rf /tmp/* && \
52+
npm cache clean --force > /dev/null 2>&1 && \
53+
rm -rf "$HOME/.npm/" && \
54+
### Add user
55+
adduser "$USERNAME" && \
56+
### Set permissions
57+
chown -R "$USERNAME":"$USERNAME" "$PLAYWRIGHT_BROWSERS_PATH";
58+
59+
USER $USERNAME
60+
WORKDIR /home/$USERNAME

playwright-installer/package-lock.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playwright-installer/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "playwright-installer",
3+
"description": "Playwright installer for Serenity/JS",
4+
"version": "1.0.0",
5+
"private": true,
6+
"author": {
7+
"name": "Jan Molak",
8+
"email": "jan.molak@smartcodeltd.co.uk",
9+
"url": "https://janmolak.com"
10+
},
11+
"homepage": "https://serenity-js.org",
12+
"license": "Apache-2.0",
13+
"dependencies": {
14+
"@playwright/test": "1.56.1"
15+
}
16+
}

0 commit comments

Comments
 (0)