fbraz3/lnmp

By fbraz3

•Updated 7 days ago

An easy-to-use LNMP/LEMP image, with Ubuntu Linux, Nginx, MySQL, PHP-FPM and PHPMyAdmin =)

Image
Languages & frameworks
Developer tools
Web servers
43

50K+

fbraz3/lnmp repository overview

Build Base Images Build Phalcon Images Ask DeepWiki

⁠Braz LEMP Docker Image

This repository provides Docker images for LNMP stack (Linux, Nginx, MariaDB, and PHP-FPM), commonly referred to as LEMP.

It is designed to simplify the deployment of PHP applications with a robust and modern environment, offering both Development and Production versions to meet different deployment needs.

The images are built on top of other modular images from the fbraz3 ecosystem, ensuring flexibility, maintainability, and ease of use.

šŸ’” For a complete list of available images, please visit the PHP System Docs⁠ page.

⁠Table of Contents

⁠Image Versions

This project provides two distinct versions for different use cases:

⁠Development Version (-dev suffix)
  • Purpose: Designed for local development and testing
  • Features:
    • MariaDB with no root password (empty password)
    • phpMyAdmin accessible at /pma/ endpoint
    • Relaxed security settings for ease of development
    • Direct database access without authentication
⁠Production Version (no suffix)
  • Purpose: Optimized for production environments
  • Features:
    • MariaDB with mandatory root password configuration
    • Enforced password security: Container will fail to start if using default password
    • Custom SQL scripts support: Execute custom SQL files at startup
    • No phpMyAdmin included for security
    • Secure database configuration
    • Root password configurable via environment variables
    • Anonymous users and test databases removed
    • Enhanced security settings

⁠Tags

The image follows a consistent tagging scheme:

⁠Base Images (Vanilla LNMP Stack)
  • Production: fbraz3/lnmp:{php_version} (e.g., 8.2, 8.3, 8.4)
  • Development: fbraz3/lnmp:{php_version}-dev (e.g., 8.2-dev, 8.3-dev)
⁠Phalcon Images (With Phalcon Framework)
  • Production: fbraz3/lnmp:{php_version}-phalcon (e.g., 8.2-phalcon, 8.3-phalcon)
  • Development: fbraz3/lnmp:{php_version}-phalcon-dev (e.g., 8.2-phalcon-dev)
⁠Latest Tags
  • fbraz3/lnmp:latest - Latest production version
  • fbraz3/lnmp:latest-dev - Latest development version
  • fbraz3/lnmp:latest-phalcon - Latest Phalcon production version
  • fbraz3/lnmp:latest-phalcon-dev - Latest Phalcon development version
⁠Architecture Support
  • All images support both amd64 and arm64 architectures
  • LEMP variants are also available as fbraz3/lemp:{tag}

⁠Flavors

This image supports multiple flavors to cater to different use cases:

  • Vanilla: A standard LNMP stack with no additional frameworks
  • Phalcon: Includes the Phalcon PHP framework pre-installed

⁠How to Use

⁠Development Version

Perfect for local development with easy database access and debugging tools.

# docker-compose.yml
services:
  web:
    image: fbraz3/lnmp:8.4-dev  # or fbraz3/lnmp:8.4-phalcon-dev
    volumes:
      - ./:/app/public/
    ports:
      - "127.0.0.1:80:80"
      - "127.0.0.1:3306:3306"

Access Points:

  • Application: http://localhost/
  • phpMyAdmin: http://localhost/pma/
  • Database: localhost:3306 (user: root, password: empty)
⁠Production Version

Secure configuration suitable for production environments.

# docker-compose.yml
services:
  web:
    image: fbraz3/lnmp:8.4  # or fbraz3/lnmp:8.4-phalcon
    environment:
      - MYSQL_ROOT_PASSWORD=your_secure_password_here
      - MYSQL_APP_DATABASE=my_application  # Optional: create app database
      - MYSQL_APP_USER=app_user            # Optional: create app user
      - MYSQL_APP_USER_PASSWD=app_password # Optional: app user password
    volumes:
      - ./:/app/public/
      - mysql_data:/var/lib/mysql
    ports:
      - "80:80"
    restart: unless-stopped

volumes:
  mysql_data:

Access Points:

  • Application: http://your-domain/
  • Database: Internal access only (user: root, password: set via environment)

Important: Always set a strong MYSQL_ROOT_PASSWORD in production!

⁠Custom SQL Scripts

The production images support executing custom SQL scripts during container startup. This feature allows you to initialize your database with custom schema, data, or configuration.

⁠How to Use Custom SQL Scripts
  1. Create your SQL files: Place your .sql files in a directory on your host system
  2. Mount the directory: Bind-mount your SQL scripts directory to /sql-scripts in the container
  3. Automatic execution: All .sql files in the directory will be executed automatically during first startup
⁠Example Usage
# docker-compose.yml
services:
  web:
    image: fbraz3/lnmp:8.4
    environment:
      - MYSQL_ROOT_PASSWORD=your_secure_password_here
    volumes:
      - ./:/app/public/
      - ./sql-scripts:/sql-scripts  # Mount your custom SQL scripts
      - mysql_data:/var/lib/mysql
    ports:
      - "80:80"
    restart: unless-stopped
# Directory structure example
project/
ā”œā”€ā”€ sql-scripts/
│   ā”œā”€ā”€ 01-create-users.sql
│   ā”œā”€ā”€ 02-create-tables.sql
│   └── 03-insert-data.sql
└── docker-compose.yml
⁠Important Notes
  • SQL scripts are executed only on first startup (when database is initialized)
  • Scripts are executed in alphabetical order
  • Use numeric prefixes (e.g., 01-, 02-) to control execution order
  • All scripts run with root privileges
  • This feature is only available in production images for security reasons

⁠Security Considerations

⁠Development Version
  • āš ļø Never use development images in production
  • Database has no root password
  • phpMyAdmin is publicly accessible
  • Intended for local development only
⁠Production Version
  • āœ… Secure by default
  • Mandatory root password
  • No phpMyAdmin interface
  • Anonymous users removed
  • Test databases removed
  • Database binds to localhost only

⁠Environment Variables

⁠Production Images
VariableRequiredDefaultDescription
MYSQL_ROOT_PASSWORDYesdefaultrootpasswordRoot password for MariaDB
MYSQL_APP_DATABASENo-Create application database
MYSQL_APP_USERNo-Create application user
MYSQL_APP_USER_PASSWDNo-Password for application user

Example:

docker run -e MYSQL_ROOT_PASSWORD=mySecurePassword123 \
           -e MYSQL_APP_DATABASE=my_app \
           -e MYSQL_APP_USER=app_user \
           -e MYSQL_APP_USER_PASSWD=app_secure_password \
           fbraz3/lnmp:8.4

Note:

  • When MYSQL_APP_USER and MYSQL_APP_USER_PASSWD are provided, the user will be granted full privileges on the database specified by MYSQL_APP_DATABASE (if provided).
  • Important: MYSQL_APP_USER and MYSQL_APP_USER_PASSWD must be used together. Creating a user without a password is a security risk and is not supported.
⁠Development Images

Development images don't require any specific environment variables and work out of the box.

⁠Manage PHP Directives via Environment Variables

This image allows you to customize PHP directives using environment variables.

For detailed instructions, refer to the php-fpm-docker documentation⁠.

⁠Cronjobs

Cronjobs can be configured by binding a file to /cronfile in the container. The system will automatically install and execute the jobs.

For more details, see the php-fpm-docker documentation⁠.

⁠Sending Mails

To enable email sending, this image relies on the configuration provided in the php-base-docker project.

Follow the instructions in the php-base-docker documentation⁠ to set up email functionality.

⁠Contribution

Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.

Please visit the CONTRIBUTING.md⁠ file for guidelines on how to contribute to this project.

⁠Donation

I spend a lot of time and effort maintaining this project. If you find it useful, consider supporting me with a donation:

⁠License

This project is licensed under the Apache License 2.0⁠, so you can use it for personal and commercial projects. However, please note that the images are provided "as is" without any warranty or guarantee of any kind. Use them at your own risk.

Tag summary

Content type

Image

Digest

sha256:09a4b0bbe…

Size

344.6 MB

Last updated

7 days ago

docker pull fbraz3/lnmp:7.0-phalcon