Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #11

Open
wants to merge 5 commits into
base: full-php-8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ FROM adhocore/phpfpm:8.0
MAINTAINER Jitendra Adhikari <[email protected]>

ENV \
ADMINER_VERSION=4.7.8 \
ADMINER_VERSION=4.8.1 \
ES_HOME=/usr/share/java/elasticsearch \
PATH=/usr/share/java/elasticsearch/bin:$PATH

RUN \
# install
apk add -U --no-cache \
beanstalkd \
elasticsearch \
# elasticsearch \
memcached \
mysql mysql-client \
nano \
Expand All @@ -20,13 +20,13 @@ RUN \
redis \
supervisor \
# elastic setup
&& rm -rf $ES_HOME/plugins \
&& mkdir -p $ES_HOME/tmp $ES_HOME/data $ES_HOME/logs $ES_HOME/plugins $ES_HOME/config/scripts \
&& mv /etc/elasticsearch/* $ES_HOME/config/ \
# elastico user
&& deluser elastico && addgroup -S elastico \
&& adduser -D -S -h /usr/share/java/elasticsearch -s /bin/ash -G elastico elastico \
&& chown elastico:elastico -R $ES_HOME \
# && rm -rf $ES_HOME/plugins \
# && mkdir -p $ES_HOME/tmp $ES_HOME/data $ES_HOME/logs $ES_HOME/plugins $ES_HOME/config/scripts \
# && mv /etc/elasticsearch/* $ES_HOME/config/ \
# # elastico user
# && deluser elastico && addgroup -S elastico \
# && adduser -D -S -h /usr/share/java/elasticsearch -s /bin/ash -G elastico elastico \
# && chown elastico:elastico -R $ES_HOME \
# rabbitmq
# && echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
# && apk add -U rabbitmq-server@testing \
Expand All @@ -53,15 +53,15 @@ COPY php/index.php /var/www/html/index.php
# supervisor config
COPY \
beanstalkd/beanstalkd.ini \
elastic/elasticsearch.ini \
mail/mailcatcher.ini \
# elasticsearch/elasticsearch.ini \
mailcatcher/mailcatcher.ini \
memcached/memcached.ini \
mysql/mysqld.ini \
mysql/mysql.ini \
nginx/nginx.ini \
pgsql/postgres.ini \
pgsql/pgsql.ini \
php/php-fpm.ini \
# rabbitmq/rabbitmq-server.ini \
redis/redis-server.ini \
# rabbitmq/rabbitmq.ini \
redis/redis.ini \
/etc/supervisor.d/

# entrypoint
Expand Down
51 changes: 41 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
## docker-lemp

![Docker Build](https://img.shields.io/docker/cloud/build/adhocore/lemp?style=flat-square)
[![Donate 15](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square&label=donate+15)](https://www.paypal.me/ji10/15usd)
[![Donate 25](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square&label=donate+25)](https://www.paypal.me/ji10/25usd)
[![Donate 50](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square&label=donate+50)](https://www.paypal.me/ji10/50usd)
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Complete+LEMP+fullstack+for+local+development+using+docker&url=https://github.com/adhocore/docker-lemp&hashtags=docker,lemp,fullstack,localdev)


> Do not use this LEMP in Production.
> For production, use [adhocore/phpfpm](https://github.com/adhocore/docker-phpfpm)
> then [compose](https://docs.docker.com/compose/install/) a stack using individual `nginx`, `redis`, `mysql` etc images.

[`adhocore/lemp`](https://hub.docker.com/r/adhocore/lemp) is a minimal single container LEMP full stack for local development.

> If you want to use PHP7.4 on LEMP stack then head over to
[`adhocore/lemp:7.4`](https://github.com/adhocore/docker-lemp/tree/7.4).
> If you want to use PHP7.4 on LEMP stack then head over to [`adhocore/lemp:7.4`](7.4.Dockerfile).

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

The docker container `adhocore/lemp` is composed of:

Name | Version | Port
--------------|------------|------
adminer | 4.7.8 | 80
adminer | 4.8.1 | 80
alpine | 3.12 | -
beanstalkd | 1.11 | 11300
elasticsearch | 6.4.3 | 9200,9300
elasticsearch`*` | 6.4.3 | 9200,9300
mailcatcher | 0.7.1 | 88
memcached | 1.6.6 | 11211
MySQL`*` | 5.7 | 3306
MySQL`**` | 5.7 | 3306
nginx | 1.18.0 | 80
phalcon | 4.0.0 | -
PHP | 8.0.3 | 9000
PostgreSQL | 12.3 | 5432
PHP8.0 | 8.0.12 | 9000
PHP7.4 | 7.4.25 | 9000
PostgreSQL | 12.6 | 5432
~rabbitmq~ | 3.8.* | 5672
redis | 5.0.9 | 6379
swoole | 4.4.12 | -
redis | 5.0.11 | 6379
swoole | 4.5.9 | -

> `*`: It is actually MariaDB 10.4.17.
> `*`: Latest versions of alpine (3.13+) seems to have removed `elasticsearch` binary!
> `**`: It is actually MariaDB 10.4.17.

## Usage

Expand All @@ -41,6 +50,9 @@ Also recommended to install [docker-compose](https://docs.docker.com/compose/ins
# pull latest image
docker pull adhocore/lemp:8.0

# or if you use php 7.4, replace 8.0 with 7.4:
docker pull adhocore/lemp:7.4

# Go to your project root then run
docker run -p 8080:80 -p 8888:88 -v `pwd`:/var/www/html --name lemp -d adhocore/lemp:8.0

Expand Down Expand Up @@ -172,6 +184,25 @@ Either your app has `public/` folder or not, the rewrite adapts automatically.

For available extensions, check [adhocore/phpfpm#extension](https://github.com/adhocore/docker-phpfpm/tree/8.0#extensions).

### Disabling services

[Pass in env var](https://www.cloudsavvyit.com/14081/how-to-pass-environment-variables-to-docker-containers/)
`DISABLE` to the container in CSV format to disable services.
The service names must be one or more of below in comma separated format:
```
beanstalkd
mailcatcher
memcached
mysql
pgsql
redis
```

> Example: `DISABLE=beanstalkd,mailcatcher,memcached,pgsql,redis`
> Essential services like `nginx`, `php`, `adminer` cannot be disabled ;).

The service(s) will be enabled again if you run the container next time without `DISABLE` env or if you remove specific services from `DISABLE` CSV.

### Testing mailcatcher

```sh
Expand Down
18 changes: 16 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD:-123456}
PGSQL_ROOT_PASSWORD=${PGSQL_ROOT_PASSWORD:-1234567890}
PGSQL_PASSWORD=${PGSQL_PASSWORD:-123456}

DISABLE=",$DISABLE,"

for S in beanstalkd elasticsearch mailcatcher memcached mysql pgsql rabbitmq redis; do
DS=$(echo $DISABLE | grep -q ",$S," && echo "YES" || echo "NO")
if [ "$DS" == "YES" ]; then
if [[ -f "/etc/supervisor.d/$S.ini" ]]; then mv "/etc/supervisor.d/$S.ini" "/etc/supervisor.d/$S"; fi
else
if [[ -f "/etc/supervisor.d/$S" ]]; then mv "/etc/supervisor.d/$S" "/etc/supervisor.d/$S.ini"; fi
fi
done

DISABLE_MYSQL=$(echo $DISABLE | grep -q ",mysql," && echo "YES" || echo "NO")
DISABLE_PGSQL=$(echo $DISABLE | grep -q ",pgsql," && echo "YES" || echo "NO")

# init nginx
if [ ! -d "/var/tmp/nginx/client_body" ]; then
mkdir -p /run/nginx /var/tmp/nginx/client_body
chown nginx:nginx -R /run/nginx /var/tmp/nginx/
fi

# init mysql
if [ ! -f "/run/mysqld/.init" ]; then
if [ "$DISABLE_MYSQL" != "YES" ] && [ ! -f "/run/mysqld/.init" ]; then
[[ "$MYSQL_USER" = "root" ]] && echo "Please set MYSQL_USER other than root" && exit 1

SQL=$(mktemp)
Expand Down Expand Up @@ -46,7 +60,7 @@ if [ ! -f "/run/mysqld/.init" ]; then
fi

# init pgsql
if [ ! -f /run/postgresql/.init ]; then
if [ "$DISABLE_PGSQL" != "YES" ] && [ ! -f /run/postgresql/.init ]; then
[[ "$PGSQL_USER" = "postgres" ]] && echo "Please set PGSQL_USER other than postgres" && exit 1

SQL=$(mktemp)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.