Skip to content

Commit 4311525

Browse files
authored
docs: add Dockerfile example (#424)
1 parent 7d37ad0 commit 4311525

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Dockerfile.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Stage 1: Modules caching
2+
FROM golang:1.21 as modules
3+
COPY go.mod go.sum /modules/
4+
WORKDIR /modules
5+
RUN go mod download
6+
7+
# Stage 2: Build
8+
FROM golang:1.21 as builder
9+
COPY --from=modules /go/pkg /go/pkg
10+
COPY . /workdir
11+
WORKDIR /workdir
12+
# Install playwright cli with right version for later use
13+
RUN PWGO_VER=$(grep -oE "playwright-go v\S+" /workdir/go.mod | sed 's/playwright-go //g') \
14+
&& go install github.com/playwright-community/playwright-go/cmd/playwright@${PWGO_VER}
15+
# Build your app
16+
RUN GOOS=linux GOARCH=amd64 go build -o /bin/myapp
17+
18+
# Stage 3: Final
19+
FROM ubuntu:jammy
20+
COPY --from=builder /go/bin/playwright /bin/myapp /
21+
RUN apt-get update && apt-get install -y ca-certificates tzdata \
22+
# Install dependencies and all browsers (or specify one)
23+
&& /playwright install --with-deps \
24+
&& rm -rf /var/lib/apt/lists/*
25+
CMD ["/myapp"]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func main() {
103103
}
104104
```
105105

106+
## Docker
107+
Refer to the [Dockerfile.example](./Dockerfile.example) to build your own docker image.
108+
106109
## More examples
107110

108111
* Refer to [helper_test.go](./tests/helper_test.go) for End-To-End testing

0 commit comments

Comments
 (0)