Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A single container LEMP complete fullstack with latest release of PHP8.0.30/8.1.29/8.2.23/8.3.11, MySQL, nginx, PostgreSQL, mailcatcher, beanstalkd, elasticsearch, memcached, redis, adminer and all you ever need; on top alpine3.17+ for both arm and amd arch

License

NotificationsYou must be signed in to change notification settings

adhocore/docker-lemp

Repository files navigation

Docker buildTweetSupport

Do not use this LEMP in Production.For production, useadhocore/phpfpmthencompose a stack using individualnginx,redis,mysql etc images.

adhocore/lemp is a minimal single container LEMP full stack for local development.

It is quick jumpstart for onboarding you into docker based development.The download size is just about ~350MB which is tiny considering how much tools and stuffs it contains.

The docker containeradhocore/lemp is composed of:

NameVersionPort
adminerevo4.8.480
alpine3.16-
beanstalkd1.1211300
elasticsearch6.4.39200,9300
mailcatcher0.7.188,25
memcached1.6.1511211
MySQL*5.73306
nginx1.21.180
phalcon"5.0.3-
PHP8.3+>=8.3.49000
PHP8.2+>=8.2.179000
PHP8.1+>=8.1.279000
PHP8.0+>=8.0.309000
PHP7.4~>=7.4.339000
PostgreSQL14.75432
rabbitmq^3.8.*5672
redis7.0.106379
swoole"4.8.9-

*: ActuallyMariaDB 10.6.12.

+: Different image tags each, viz:8.3,:8.2,:8.1,:8.0 and:7.4.

~: PHP 7.4 has reached end of life and isdeprecated.

": swoole, phalcon have been disabled for now in order to optimize and speed up multiplatform builds (amd64/arm64) but can beadded back.

Usage

Installdocker in your machine.Also recommended to installdocker-compose.

# pull latest imagedocker pull adhocore/lemp:8.3# or with PHP8.2docker pull adhocore/lemp:8.2# or with PHP8.1docker pull adhocore/lemp:8.1# or with PHP8.0docker pull adhocore/lemp:8.0# or if you *still* use php 7.4 (which you should not):docker pull adhocore/lemp:7.4# Go to your project root then rundocker run -p 8080:80 -p 8888:88 -v`pwd`:/var/www/html --name lemp -d adhocore/lemp:8.3# In windows, you would use %cd% instead of `pwd`docker run -p 8080:80 -p 8888:88 -v %cd%:/var/www/html --name lemp -d adhocore/lemp:8.3# If you want to setup MySQL credentials, pass env varsdocker run -p 8080:80 -p 8888:88 -v`pwd`:/var/www/html \  -e MYSQL_ROOT_PASSWORD=1234567890 -e MYSQL_DATABASE=appdb \  -e MYSQL_USER=dbuser -e MYSQL_PASSWORD=123456 \  --name lemp -d adhocore/lemp:8.2# for postgres you can pass in similar env as for mysql but with PGSQL_ prefix

After running container as above, you will be able to browselocalhost:8080!

The database adminerevo will be available formysqlandpostgres.

The mailcatcher will be available atlocalhost:8888 which displays mails in realtime.

Stop container

To stop the container, you would run:

docker stop lemp

(Re)Start container

You dont have to always dodocker run as in above unless you removed or lost yourlemp container.

Instead, you can just start when needed:

docker start lemp

PRO If you develop multiple apps, you can create multiple lemp containers with different names.

eg:docker run -p 8081:80 -v $(pwd):/var/www/html --name new-lemp -d adhocore/lemp:8.3

With Docker compose

Create adocker-compose.yml in your project root with contents something similar to:

# ./docker-compose.ymlversion:'3'services:app:image:adhocore/lemp:8.3# For different app you can use different names. (eg: )container_name:some-appvolumes:# app source code      -./path/to/your/app:/var/www/html# db data persistence      -db_data:/var/lib/mysql# Here you can also volume php ini settings# - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.iniports:      -8080:80environment:MYSQL_ROOT_PASSWORD:supersecurepwdMYSQL_DATABASE:appdbMYSQL_USER:dbusrMYSQL_PASSWORD:securepwd# for postgres you can pass in similar env as for mysql but with PGSQL_ prefixvolumes:db_data:{}

Then all you gotta do is:

# To startdocker-compose up -d# To stopdocker-compose stop

As you can see using compose is very neat, intuitive and easy.Plus you can already set the volumes and ports there, so you dont have to type in terminal.

MySQL Default credentials

  • root password: 1234567890 (ifMYSQL_ROOT_PASSWORD is not passed)
  • user password: 123456 (ifMYSQL_USER is passed butMYSQL_PASSWORD is not)

PgSQL Default credentials

  • postgres password: 1234567890 (ifPGSQL_ROOT_PASSWORD is not passed)
  • user password: 123456 (ifPGSQL_USER is passed butPGSQL_PASSWORD is not)

Accessing DB

In PHP app you can access MySQL db via PDO like so:

$db =newPDO('mysql:host=127.0.0.1;port=3306;dbname=' .getenv('MYSQL_DATABASE'),getenv('MYSQL_USER'),getenv('MYSQL_PASSWORD'));

You can access PgSQL db via PDO like so:

$pdb =newPDO('pgsql:host=127.0.0.1;port=5432;dbname=' .getenv('PGSQL_DATABASE'),getenv('PGSQL_USER'),getenv('PGSQL_PASSWORD'));

Nginx

URL rewrite is already enabled for you.

Either your app haspublic/ folder or not, the rewrite adapts automatically.

PHP

For available extensions, checkadhocore/phpfpm#extensions.

Disabling services

Pass in env varDISABLE to the container in CSV format to disable services.The service names must be one or more of below in comma separated format:

beanstalkdmailcatchermemcachedmysqlpgsqlredis

Example:DISABLE=beanstalkd,mailcatcher,memcached,pgsql,redisEssential services likenginx,php,adminerevo cannot be disabled ;).

The service(s) will be enabled again if you run the container next time withoutDISABLE env or if you remove specific services fromDISABLE CSV.

Testing mailcatcher

# open shelldockerexec -it lemp sh# send test mailecho"\n"| sendmail -S 0 test@localhost

Then you will see the new mail in realtime athttp://localhost:8888.

Or you can check it in shell as well:

curl 0:88/messages

About

A single container LEMP complete fullstack with latest release of PHP8.0.30/8.1.29/8.2.23/8.3.11, MySQL, nginx, PostgreSQL, mailcatcher, beanstalkd, elasticsearch, memcached, redis, adminer and all you ever need; on top alpine3.17+ for both arm and amd arch

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp