Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 14, 2025

Problem

The production Docker images set zsh as the default shell (via useradd -s /bin/zsh), but no .zshrc configuration file was being copied to the production stage. This resulted in an unconfigured zsh shell when users interacted with production containers, potentially causing a suboptimal user experience or errors when zsh-specific features were expected.

Solution

Created a production-appropriate .zshrc.prod configuration file and updated both Dockerfile variants (Bookworm and Alpine) to copy it into production images.

Changes

  1. New file: .zshrc.prod (56 lines)

    • Sources env.sh to make Laravel/PHP aliases available (pint, pa, stan, pest, etc.)
    • Configures Oh My Zsh with only the basic git plugin (included by default)
    • Includes essential zsh features: history management, keybindings, tab completion
    • Conditionally initializes FNM if available
    • Deliberately excludes dev-only dependencies (starship, eza, fzf, gh, zoxide, custom plugins)
  2. Updated production stages in both Dockerfile and alpine.Dockerfile

    USER root
    COPY --chown=${USER}:${USER} ./.zshrc.prod /home/${USER}/.zshrc
    USER ${USER}
  3. Updated README-ALPINE.md

    • Moved zsh from development-only to base features
    • Clarified that dev images have enhanced zsh configuration with additional plugins
    • Added .zshrc.prod to file structure documentation
  4. Enhanced test.php to include missing dev-only binaries

    • Added fzf (fuzzy finder)
    • Added eza (modern ls replacement)
    • Added starship (shell prompt)
    • Added zoxide (smarter cd command)
    • Added opencode (code editor)
    • These binaries are now properly validated as dev-only tools

Dev vs Production Configuration

Aspect Development (.zshrc) Production (.zshrc.prod)
Plugins git, zsh-autosuggestions, zsh-syntax-highlighting, fast-syntax-highlighting, aws, gh, zoxide, fzf, fzf-tab git only
Prompt Starship (custom prompt) Default Oh My Zsh prompt
Tools eza, fzf, zoxide, gh Standard commands only
Size 83 lines 56 lines

Benefits

  • ✅ Production containers now have a functional, properly configured zsh shell
  • ✅ No errors when users interact with the production shell
  • ✅ Lightweight configuration that doesn't bloat the image
  • ✅ Clear separation between development and production environments
  • ✅ Consistent experience across both Bookworm and Alpine variants
  • ✅ Laravel/PHP aliases remain available in production environments
  • ✅ Comprehensive test coverage for all dev-only binaries

Testing

Users can verify the fix by running:

docker run --rm -it <prod-image> zsh -c "echo 'Zsh is working!'"

The test script now validates all binaries including fzf and other dev-only tools to ensure proper separation between production and development environments.

Original prompt

in the production image, we also set the default shell to be zsh but there's no zshrc for production. plz address that


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 14, 2025 22:47
Co-authored-by: munezaclovis <51137458+munezaclovis@users.noreply.github.com>
Co-authored-by: munezaclovis <51137458+munezaclovis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add default zshrc for production images Add .zshrc configuration for production Docker images Oct 14, 2025
Copilot AI requested a review from munezaclovis October 14, 2025 22:56
@munezaclovis
Copy link
Collaborator

@copilot add fzf to the test.php script. I noticed some commands/binaries we need are not being tested. also Add any other binaries missing to the script

Co-authored-by: munezaclovis <51137458+munezaclovis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 15, 2025

@copilot add fzf to the test.php script. I noticed some commands/binaries we need are not being tested. also Add any other binaries missing to the script

Added fzf and other missing dev-only binaries to test.php. The DEV_ONLY_BINARIES array now includes: fzf, eza, starship, zoxide, and opencode (in addition to the existing gh, htop, nano). These are all tools installed in the dev stage but not in production. (commit 0f94a23)

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