Skip to content

fix(memcached): use multi-stage build to resolve permission denied on mkdir/chmod#344

Merged
bdossantos merged 3 commits into
masterfrom
copilot/fix-chmod-permissions-error
Jun 15, 2026
Merged

fix(memcached): use multi-stage build to resolve permission denied on mkdir/chmod#344
bdossantos merged 3 commits into
masterfrom
copilot/fix-chmod-permissions-error

Conversation

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The official memcached base image sets a non-root USER, so any RUN instruction in a derived image fails when touching system directories like /usr/local/lib/.

Changes

  • Multi-stage build: Added a debian:13-slim (Trixie, matching the memcached:1.6.42-trixie runtime) build stage that runs as root to create /usr/local/lib/memcached and fetch routelib.lua via ADD --checksum
  • Runtime stage: Replaced the failing RUN mkdir/chmod + ADD with COPY --from=build --chown=65534:65534 — no root operations needed in the final stage
# Build (runs as root)
FROM debian:13-slim@sha256:... AS build
RUN mkdir -p /usr/local/lib/memcached && chmod 755 /usr/local/lib/memcached
ADD --chmod=644 --checksum=sha256:... https://.../routelib.lua /usr/local/lib/memcached/routelib.lua

# Run (non-root memcache user from base image)
FROM memcached:1.6.42-trixie@sha256:...
COPY --from=build --chown=65534:65534 /usr/local/lib/memcached /usr/local/lib/memcached

@bdossantos bdossantos marked this pull request as ready for review June 15, 2026 12:51
Copilot AI review requested due to automatic review settings June 15, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the memcached Dockerfile to prevent a build failure (chmod: Operation not permitted) by ensuring /usr/local/lib/memcached is created with the intended permissions before a remote ADD places routelib.lua into it.

Changes:

  • Create /usr/local/lib/memcached explicitly via RUN mkdir -p ... && chmod 755 ... prior to the ADD.
  • Remove the post-ADD RUN chmod 755 /usr/local/lib/memcached step, since the directory is now prepared ahead of time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI changed the title fix(memcached): resolve chmod "Operation not permitted" on /usr/local/lib/memcached fix(memcached): use multi-stage build to resolve permission denied on mkdir Jun 15, 2026
Copilot AI requested a review from bdossantos June 15, 2026 12:55
Copilot AI changed the title fix(memcached): use multi-stage build to resolve permission denied on mkdir fix(memcached): use multi-stage build to resolve permission denied on mkdir/chmod Jun 15, 2026
@bdossantos bdossantos merged commit a19df63 into master Jun 15, 2026
1 of 17 checks passed
@bdossantos bdossantos deleted the copilot/fix-chmod-permissions-error branch June 15, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants