Skip to content

Commit aa31130

Browse files
committed
fix(Dockerfile): make sure we run as a user
When we start the current code from the container build, we're getting ```console Error: unable to set up OpenTelemetry SDK: failed to create initial resources: error detecting resource: user: Current requires cgo or $USER set in environment ``` This is because, in commit 09b72e0, we added `resource.WithProcess()` to include process information in the exported resources. One of the fields this looks up is the username of the process's UID. Since we are using a `scratch` image, unless we put them there there are no users or groups present. The `os/user` package errors with the message above if it can't find the user. The minimal fix we're doing here is to create a user and a group for us to run as, so that this lookup succeeds inside the container.
1 parent f831373 commit aa31130

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ RUN --mount=target=. \
2020

2121
FROM scratch
2222

23+
COPY <<EOF /etc/group
24+
nogroup:x:65534:
25+
EOF
26+
27+
COPY <<EOF /etc/passwd
28+
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
29+
EOF
30+
31+
USER nobody:nogroup
32+
2333
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2434
COPY --from=builder /usr/bin/flux-commit-tracker /usr/bin/flux-commit-tracker
2535

0 commit comments

Comments
 (0)