fix: drop openrc in runner images: missing pids in cgroups setup

This commit is contained in:
Paul Pan 2024-01-27 19:54:09 +08:00
parent 362b5ea9ba
commit 025c88ca6b
Signed by: Paul
GPG Key ID: D639BDF5BA578AF4
2 changed files with 16 additions and 7 deletions

View File

@ -20,7 +20,7 @@ RUN --mount=type=cache,id=golang,target=/go/pkg make build
FROM docker.io/library/alpine
WORKDIR /app
RUN apk --no-cache add tzdata ca-certificates bash openrc \
RUN apk --no-cache add tzdata ca-certificates bash tini \
containerd nerdctl
# sources
@ -29,4 +29,5 @@ COPY --from=builder /builder/config.docker.yaml /app
COPY --from=builder /builder/docker-entrypoint.sh /app
COPY --from=builder /builder/woj /app
ENTRYPOINT ["/app/docker-entrypoint.sh"]
# reap zombies from containerd-shim
ENTRYPOINT ["/sbin/tini", "/app/docker-entrypoint.sh"]

View File

@ -118,11 +118,19 @@ function generate_config() {
}
startup_containerd() {
rc-status
touch /run/openrc/softlevel
rc-update add containerd default
rc-service containerd start
rc-service containerd status
# taken from https://github.com/moby/moby/blob/ee6cbc540e9c62feb143c2a8d3f0c86d2a468767/hack/dind#L59-L69
# cgroup v2: enable nesting
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
# move the processes from the root group to the /init group,
# otherwise writing subtree_control fails with EBUSY.
# An error during moving non-existent process (i.e., "cat") is ignored.
mkdir -p /sys/fs/cgroup/init
xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || :
# enable controllers
sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \
> /sys/fs/cgroup/cgroup.subtree_control
fi
nohup containerd &
log_info 'containerd started'
}