Skip to content

Commit

Permalink
Add Dockerfile and Docker build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
thmshmm committed Mar 15, 2024
1 parent 0638bfb commit e971cb4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.22 AS build
WORKDIR /go/src/github.com/thmshmm/xk6-opentelemetry
COPY . .
RUN go install go.k6.io/xk6/cmd/xk6@latest
RUN xk6 build --with xk6-opentelemetry=. --with github.com/mostafa/xk6-kafka

FROM alpine:latest as base
RUN apk add --no-cache ca-certificates && \
addgroup -S app && adduser -S -G app app

FROM scratch
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=base /etc/passwd /etc/passwd
COPY --from=build /go/src/github.com/thmshmm/xk6-opentelemetry/k6 /k6
USER app
ENTRYPOINT ["/k6"]
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ Check the [examples](./examples/) directory which contains some scripts to get s
- ExportTraceServiceRequest
- Set resource attributes

## Development
## Usage

### Docker

The easiest way to get started is to build the provided Docker image and run k6 scripts inside the container.

Build the image:
```
docker build -t xk6-opentelemetry .
```

Run a local k6 script:
```
docker run --rm -i xk6-opentelemetry run - <my-script.js
```

### Local build

As the testing environment and scripts rely on sending messages to Kafka, the extension [xk6-kafka](https://github.com/mostafa/xk6-kafka) needs to be integrated as well when creating the k6 binary.

Expand Down
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ tasks:
cmds:
- xk6 build --with xk6-opentelemetry=. --with github.com/mostafa/xk6-kafka

build-docker:
cmds:
- docker build -t xk6-opentelemetry .

lint:
cmds:
- golangci-lint run
Expand Down

0 comments on commit e971cb4

Please sign in to comment.