Skip to content

fix(ols): Fix OLS permission issue caused by binding to uid 1000#19

Merged
alaminfirdows merged 8 commits intoflywp:mainfrom
ma-04:ols_user_perm_fix
Jul 17, 2025
Merged

fix(ols): Fix OLS permission issue caused by binding to uid 1000#19
alaminfirdows merged 8 commits intoflywp:mainfrom
ma-04:ols_user_perm_fix

Conversation

@ma-04
Copy link
Copy Markdown
Member

@ma-04 ma-04 commented Jun 20, 2025

Fixes #49

Proposed changes

  • Add support for two environment variables, PUID and PGID, that allows FlyWP to override the user and group IDs used inside the container.

  • set these variables in docker-compose.yml, if no variables exist, use the default 1000

  • Update /entrypoint.sh to read PUID and PGID (defaulting to 1000 when they are not provided) and run chown so that file permissions match the requested UID / GID before the main process starts.

With this change, the container no longer assumes that the default fly user has UID 1000, making it compatible with hosts that map container users to different IDs.

Sample docker-compose.yml

services:
  openlitespeed:
    image: 'meghsh/openlitespeed:8.2'
    restart: always
    volumes:
      - './app:/var/www/html'
      - './logs/ols:/usr/local/lsws/logs'
      - './config/php/ols.ini:/usr/local/lsws/lsphp82/etc/php/8.2/mods-available/ols.ini'
      - './config/ols/httpd_config.conf:/usr/local/lsws/conf/httpd_config.conf'
      - './config/ols/vhconf.conf:/usr/local/lsws/conf/vhosts/flywp/vhconf.conf'
      - '/home/fly/.fly/nginx/html:/usr/share/nginx/html'
    labels:
      ofelia.enabled: 'true'
      ofelia.job-exec.wpcron-17811.schedule: '@every 10m'
      ofelia.job-exec.wpcron-17811.user: www-data
      ofelia.job-exec.wpcron-17811.command: 'wp cron event run --due-now'
    environment:
      - PUID=1000
      - PGID=1000
      - VIRTUAL_HOST=domain.com
      - VIRTUAL_PORT=8080
      - CERT_NAME=2733/server
      - HTTPS_METHOD=redirect
    networks:
      - site-network
      - db-network
      - wordpress-sites
networks:
  site-network:
    name: domain.com
  wordpress-sites:
    name: wordpress-sites
    external: true
  db-network:
    name: db-network
    external: true

Summary by CodeRabbit

  • New Features

    • Added support for customizing user and group IDs for the web server via environment variables.
    • The script now displays the current and intended user/group IDs at startup for improved transparency.
  • Chores

    • Updated OpenLiteSpeed to version 1.8.3.
    • Added mysql-client to the installed packages in the container.

@ma-04 ma-04 marked this pull request as ready for review June 20, 2025 04:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the OpenLiteSpeed Docker build process. The Dockerfile now installs mysql-client, adjusts group IDs, and removes a user ID change. The build script updates OpenLiteSpeed to version 1.8.3. The entrypoint script adds environment variable checks for user/group IDs, prints relevant information at startup, and modifies user/group ID assignment logic.

Changes

File(s) Change Summary
openlitespeed/Dockerfile Added mysql-client installation, removed www-data UID change, changed lsadm GID to 999.
openlitespeed/build.sh Updated OLS_VERSION from 1.8.1 to 1.8.3.
openlitespeed/entrypoint.sh Added UID/GID printouts, separate PGID/PUID checks with defaults, updated www-data UID/GID logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Entrypoint Script
    participant OS

    User->>Entrypoint Script: Start container
    Entrypoint Script->>OS: Get current www-data UID/GID
    Entrypoint Script->>Entrypoint Script: Read PUID and PGID env vars (default 1000)
    Entrypoint Script->>Entrypoint Script: Print current and target UID/GID
    Entrypoint Script->>OS: Change www-data GID to PGID
    Entrypoint Script->>OS: Change www-data UID to PUID
    Entrypoint Script->>OS: Adjust permissions on /var/www/html
    Entrypoint Script->>OS: Start OpenLiteSpeed service
Loading

Suggested reviewers

  • alaminfirdows

Poem

In the warren where containers run,
A rabbit tweaks IDs for fun.
With MySQL tools and versions new,
The scripts now check your numbers too!
Hop along, the build is bright—
OpenLiteSpeed is set just right.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d47bcde and 0242c5f.

📒 Files selected for processing (1)
  • openlitespeed/entrypoint.sh (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
openlitespeed/entrypoint.sh (1)

17-17: Fix log message variable mix-up
The echo swaps and mislabels UID/GID. It should be:

echo "setting GID to $PGID and UID to $PUID"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3f40dd and 85d30a2.

📒 Files selected for processing (3)
  • openlitespeed/Dockerfile (3 hunks)
  • openlitespeed/build.sh (1 hunks)
  • openlitespeed/entrypoint.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: build-php (8.4)
  • GitHub Check: build-php (8.1)
  • GitHub Check: build-php (8.0)
  • GitHub Check: build-php (8.3)
  • GitHub Check: build-php (8.2)
  • GitHub Check: build-openlitespeed (7.4, lsphp74)
  • GitHub Check: build-php (7.4)
  • GitHub Check: build-openlitespeed (8.2, lsphp82)
  • GitHub Check: build-openlitespeed (8.1, lsphp81)
  • GitHub Check: build-openlitespeed (8.3, lsphp83)
🔇 Additional comments (7)
openlitespeed/Dockerfile (2)

14-14: Install mysql-client alongside existing utilities
Adding mysql-client enables in-container database tooling. Ensure this aligns with your image size and security requirements.


51-52: Release GID 1000 by remapping lsadm to 999
Verify that the lsadm group exists at this point and that GID 999 isn’t already in use on the base image to prevent groupmod from failing.

openlitespeed/build.sh (1)

6-6: Bump OpenLiteSpeed version to 1.8.3
Version bump looks correct; confirm that the 1.8.3 binaries are available and pass your smoke tests.

openlitespeed/entrypoint.sh (4)

4-5: Print current www-data UID/GID at startup
Helpful for debugging; no issues spotted here.


6-10: Separate PGID fallback logic
Explicitly defaults PGID to 1000 when unset. Consider quoting the variable in the test ([ -z "$PGID" ]).


12-15: Separate PUID fallback logic
Mirrors the PGID check—defaults PUID to 1000 when unset. Good consistency.


19-20: Apply runtime UID/GID adjustments
Modifying www-data’s group and user IDs per PGID/PUID is correct. Ensure this runs before any chown operations.

@ma-04 ma-04 force-pushed the ols_user_perm_fix branch from 1a8dd20 to d47bcde Compare July 17, 2025 09:44
@alaminfirdows alaminfirdows merged commit 2e5e00f into flywp:main Jul 17, 2025
11 of 12 checks passed
@ma-04 ma-04 deleted the ols_user_perm_fix branch July 17, 2025 10:00
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.

2 participants