Add docker-compose Playwright E2E stack
This commit is contained in:
parent
fd03a5ade3
commit
7ffec2c324
12 changed files with 359 additions and 65 deletions
17
docker/e2e/Dockerfile.e2e
Normal file
17
docker/e2e/Dockerfile.e2e
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
FROM mcr.microsoft.com/playwright:v1.55.0-jammy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
|
||||
RUN npm install -g yarn@1.22.22
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV CI=1
|
||||
|
||||
CMD ["yarn", "e2e:pw"]
|
||||
|
||||
57
docker/pleroma/entrypoint.e2e.sh
Normal file
57
docker/pleroma/entrypoint.e2e.sh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/ash
|
||||
|
||||
set -eu
|
||||
|
||||
SEED_SENTINEL_PATH="/var/lib/pleroma/.e2e_seeded"
|
||||
|
||||
echo "-- Waiting for database..."
|
||||
while ! pg_isready -U "${DB_USER:-pleroma}" -d "postgres://${DB_HOST:-db}:${DB_PORT:-5432}/${DB_NAME:-pleroma}" -t 1; do
|
||||
sleep 1s
|
||||
done
|
||||
|
||||
echo "-- Running migrations..."
|
||||
/opt/pleroma/bin/pleroma_ctl migrate
|
||||
|
||||
echo "-- Starting!"
|
||||
/opt/pleroma/bin/pleroma start &
|
||||
PLEROMA_PID="$!"
|
||||
|
||||
cleanup() {
|
||||
if [ -n "${PLEROMA_PID:-}" ] && kill -0 "$PLEROMA_PID" 2>/dev/null; then
|
||||
kill -TERM "$PLEROMA_PID"
|
||||
wait "$PLEROMA_PID" || true
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup INT TERM
|
||||
|
||||
echo "-- Waiting for API..."
|
||||
api_ok="false"
|
||||
for _i in $(seq 1 120); do
|
||||
if wget -qO- http://127.0.0.1:4000/api/v1/instance >/dev/null 2>&1; then
|
||||
api_ok="true"
|
||||
break
|
||||
fi
|
||||
sleep 1s
|
||||
done
|
||||
|
||||
if [ "$api_ok" != "true" ]; then
|
||||
echo "Timed out waiting for Pleroma API to become available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$SEED_SENTINEL_PATH" ]; then
|
||||
if [ -n "${E2E_ADMIN_USERNAME:-}" ] && [ -n "${E2E_ADMIN_PASSWORD:-}" ] && [ -n "${E2E_ADMIN_EMAIL:-}" ]; then
|
||||
echo "-- Seeding admin user (${E2E_ADMIN_USERNAME})..."
|
||||
if ! /opt/pleroma/bin/pleroma_ctl user new "$E2E_ADMIN_USERNAME" "$E2E_ADMIN_EMAIL" --admin --password "$E2E_ADMIN_PASSWORD" -y; then
|
||||
echo "-- User already exists (or creation failed), ensuring admin + confirmed..."
|
||||
/opt/pleroma/bin/pleroma_ctl user set "$E2E_ADMIN_USERNAME" --admin --confirmed
|
||||
fi
|
||||
else
|
||||
echo "-- Skipping admin seeding (missing E2E_ADMIN_* env)"
|
||||
fi
|
||||
|
||||
touch "$SEED_SENTINEL_PATH"
|
||||
fi
|
||||
|
||||
wait "$PLEROMA_PID"
|
||||
Loading…
Add table
Add a link
Reference in a new issue