Skip to content

Commit bf99a75

Browse files
committed
fix: rootless Alpine container support
Patch out chown calls that fail without CAP_CHOWN in rootless containers. Use find instead of hardcoded gem paths so patches survive Ruby and gem version changes. Signed-off-by: Simon Lauger <simon@lauger.de>
1 parent f9ba621 commit bf99a75

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

openvoxserver/Containerfile.alpine

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,15 @@ RUN sed -i 's/^ *USER="puppet"/USER=""/' /etc/default/puppetserver
224224
# `puppetserver setup` forces symlinking the "old" cadir to the "new" one for puppet 6 compatibility
225225
# reasons. this won't work because after creating a link ruby tries to call chown
226226
RUN sed -i '/Puppetserver::Ca::Utils::Config\.symlink_to_old_cadir/ s/^/# /' \
227-
/usr/lib/ruby/gems/3.4.0/gems/openvoxserver-ca-3.0.0/lib/puppetserver/ca/action/setup.rb
227+
/usr/lib/ruby/gems/*/gems/openvoxserver-ca-*/lib/puppetserver/ca/action/setup.rb
228+
# `FileUtils.chown` calls fail in rootless containers because the process
229+
# lacks CAP_CHOWN. The ownership is already handled by the g=u / SGID pattern above.
230+
RUN sed -i 's/FileUtils\.chown/# FileUtils.chown/' \
231+
/usr/lib/ruby/gems/*/gems/openvoxserver-ca-*/lib/puppetserver/ca/utils/file_system.rb
232+
# `install --owner/--group` in the foreground script requires CAP_CHOWN which
233+
# is not available in rootless containers. Replace with a simple touch + chmod.
234+
RUN sed -i 's|printf.*install -D --owner.*restartfile.*|touch "$restartfile" \&\& chmod 0644 "$restartfile"|' \
235+
/opt/puppetlabs/server/apps/puppetserver/cli/apps/foreground
228236

229237
USER puppet:0
230238

0 commit comments

Comments
 (0)