This repository aims to supply a small as possible docker environment, readily preconfigured with PHP and Nginx. Both processes (PHP and Nginx) are supervised which also is the first process (PID 1). The size of the image currently is 92.8 MB.
- supervisor
- curl
- php82-fpm
- php82-json
- php82-ldap
- php82-curl
- php82-pdo
- php82-pdo_mysql
- php82-pdo_sqlite
- php82-simplexml
- php82-dom
- php82-ctype
- php82-tokenizer
- php82-xml
- php82-xmlwriter
- php82-session
- php82-pecl-xdebug
- composer
- nginx
- make
- docker
- openssl
First, copy the file .env.dist
into the same directory but name it .env
.
Open the newly created dotenv file and adjust the containing environment variables
to your needs.
Example:
PROJECT_NAME=this-is-my-new-project-name
This variable will be used for the container, the image, the docker network and to identify which container should be used when using the make commands.
NOTICE
All 'make' commands require to be executed from the root directory, not from the ./app nor ./bin directory.
After setting your project name, execute the following command in your shell.
./your-project-name $> make first-install
This will initially pull the Alpine image and proceeds to install the mentioned packages as listed above.
Place your code inside the app
folder. Everything in there is
being mounted into the container. The Webserver is pointing to a
file named index.php
in the public
folder. The absolute
path within the container is /var/www/public
.
You can use the existing bootstrap.php
to start with your application.
Usually you'll create a src
folder beside the public
and vendor
folder.
The src
folder is where your application logic lives.
You can also include assets like JavaScript or CSS in an absolute way,
like /css/main.css
. As initially mentioned, the public
folder is the servers root directory.
./your-project-name $> make ssh
If you need to execute your own commands within the container, you can use the provided
shell script in the bin
directory. It also respects the user permissions as it's
running with the containers www
user. Because of this, your host machine will have the correct
user and permissions set when files were created within the container.
Example:
./your-project-name $> ./bin/run.sh "composer install"
You can also run commands as root, which is sometimes useful.
Example:
./your-project-name $> ./bin/run.sh "apt-get install" true
Execute the following command to enable Xdebug:
./your-project-name $> make xdebug-on
Disable it with the following command:
./your-project-name $> make xdebug-off
NOTICE
The Xdebug service is listening on Port 9003, please respect that in your configuration.
In some cases you have to rebuild your image and container, especially if you're adding
files within the rootfs
directory. In a regular setup you have to delete the whole stack
and rebuild it to prevent the docker layer cache from kicking in. Because of the way the
image is build in this repository, Docker is able to detect changes in the source of every layer.
This means you can safely just run make install
again and rely on getting your
expected changes into the container. The cache is still active for unchanged layers though.
Call localhost in your favorite Browser. You probably have to accept the custom certificate warning.