build(container): fix Caddy stage permissions by using COPY --chown and drop chown RUN to avoid rootfs perms error

This commit is contained in:
William Valentin
2025-09-09 12:57:57 -07:00
parent 5ead0d1ce9
commit eb55fb8951

View File

@@ -59,7 +59,7 @@ FROM caddy:2-alpine AS production
RUN apk add --no-cache curl
# Copy built files from builder stage
COPY --from=builder /app/dist /usr/share/caddy
COPY --from=builder --chown=caddy:caddy /app/dist /usr/share/caddy
# Configure Caddy to serve SPA with health endpoint (no TLS)
RUN cat > /etc/caddy/Caddyfile <<'CADDY'
@@ -78,8 +78,7 @@ RUN cat > /etc/caddy/Caddyfile <<'CADDY'
}
CADDY
# Set proper permissions for caddy
RUN chown -R caddy:caddy /usr/share/caddy /etc/caddy
# Permissions: using default ownership; no chown required
# Switch to caddy user
USER caddy