-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows using xk6 via Docker, without having to setup a local Go environment or install xk6. Unfortunately, file permissions with mounted volumes are still an issue[1], without a simple, native fix. fixuid[2] seems to be the modern solution to this, and works well from my tests. Part of #8 [1]: moby/moby#7198 [2]: https://github.com/boxboat/fixuid
- Loading branch information
Ivan Mirić
committed
Feb 27, 2023
1 parent
2edb8de
commit 9be35b4
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ARG GO_VERSION=1.20.1 | ||
ARG VARIANT=bullseye | ||
FROM golang:${GO_VERSION}-${VARIANT} as builder | ||
|
||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
ARG GOFLAGS="-ldflags=-w -ldflags=-s" | ||
RUN CGO_ENABLED=0 go build -o xk6 -trimpath ./cmd/xk6/main.go | ||
|
||
|
||
FROM golang:${GO_VERSION}-${VARIANT} | ||
|
||
RUN addgroup --gid 1000 xk6 && \ | ||
adduser --uid 1000 --ingroup xk6 --home /home/xk6 --shell /bin/sh --disabled-password --gecos "" xk6 | ||
|
||
ARG FIXUID_VERSION=0.5.1 | ||
RUN USER=xk6 && \ | ||
GROUP=xk6 && \ | ||
curl -fSsL https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ | ||
chown root:root /usr/local/bin/fixuid && \ | ||
chmod 4755 /usr/local/bin/fixuid && \ | ||
mkdir -p /etc/fixuid && \ | ||
printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml | ||
|
||
COPY --from=builder /build/xk6 /usr/local/bin/ | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
WORKDIR /xk6 | ||
RUN chown xk6:xk6 /xk6 | ||
USER xk6 | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
eval "$(fixuid)" | ||
|
||
exec /usr/local/bin/xk6 "$@" |