-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-playwright.dev
More file actions
82 lines (62 loc) · 2.69 KB
/
Dockerfile-playwright.dev
File metadata and controls
82 lines (62 loc) · 2.69 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# syntax=docker/dockerfile:1.23.0-labs@sha256:7eca9451d94f9b8ad22e44988b92d595d3e4d65163794237949a8c3413fbed5d
FROM golang:1.26-alpine AS builder
ARG BENCH_REVISION
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETVARIANT
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH
ARG FIXUID_VERSION=v0.6.0
RUN apk add --no-cache ca-certificates git
# build bench
WORKDIR /app
# go mod download first to cache modules for faster local builds
COPY go.mod go.sum ./
RUN --mount=type=cache,id=go-build-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/root/.cache/go-build \
--mount=type=cache,id=go-pkg-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/go/pkg \
CGO_ENABLED=0 \
go mod download -x
# now copy the rest of the source and build
COPY bench.go ./bench.go
COPY cmd ./cmd
COPY pkg ./pkg
RUN CGO_ENABLED=0 go build \
-ldflags="-X github.com/grafana/grafana-bench/pkg/revision.bench=${BENCH_REVISION}" \
-trimpath -o build/grafana-bench .
# Install fixuid for development builds
RUN go get github.com/boxboat/fixuid@${FIXUID_VERSION} && \
CGO_ENABLED=0 go build -o build/fixuid github.com/boxboat/fixuid
FROM grafana/k6:latest AS k6
# Use Playwright base image which includes all browser dependencies
FROM mcr.microsoft.com/playwright:v1.58.2-noble AS runtime
USER root
# Install additional system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates \
git \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Enable corepack and install pnpm (Node.js already included in Playwright base image)
RUN npm uninstall -g yarn pnpm # remove default yarn and pnpm
RUN npm install -g corepack@latest
RUN corepack enable # enable corepack
# install corepack packagemanagers
RUN corepack install -g npm@latest yarn@latest pnpm@latest
# Use existing pwuser from Playwright base image instead of creating bench user
# Copy binaries
COPY --from=k6 /usr/bin/k6 /usr/local/bin/k6
COPY --from=builder /app/build/grafana-bench /usr/local/bin/grafana-bench
COPY --from=builder /app/build/fixuid /usr/local/bin/fixuid
COPY docker-entrypoint-dev.sh /usr/local/bin/entrypoint.sh
# Configure fixuid for development
RUN mkdir -p /etc/fixuid && \
printf "user: pwuser\ngroup: pwuser\npaths:\n - /home/pwuser\n - /home/pwuser/.cache\n - /tests\n - /tmp\n" > /etc/fixuid/config.yml && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid
# Create /tests directory as default test location and ensure proper permissions
RUN mkdir -p /tests /home/pwuser/.cache && \
chown -R pwuser:pwuser /tests /home/pwuser/.cache
WORKDIR /tests
USER pwuser
# Call fixuid before calling bench to set the file permissions when running locally
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]