Production is a Docker image that is compact and efficient, with the sole purpose of running your web project in a production environment.
Production is a Docker image created using the Linux distribution Alpine. The PHP interpreter version 8.3 was installed, including the extensions core, date, filter, hash, json, libxml, pcre, random, readline, reflection, spl, standard, and zlib. In addition, the web server NGINX was installed to allow the efficient execution of your web projects.
To facilitate the management of processes, the Supervisor was installed, which allows the control of the execution of multiple processes, such as the web server and the PHP interpreter. The Supervisor is also responsible for monitoring and restarting processes in case of failures, ensuring greater availability of your project.
If additional adjustments are necessary, they can be made simply and easily, using the available environment variables.
Follow the steps below to build the Docker image:
- Clone the repository with the command:
git clone https://github.com/joaopinto14/Production.git
- Navigate to the project directory with the command:
cd Production
- Build the Docker image with the command:
docker build -t production .
To run your project in the Docker image Production, follow the steps below:
-
Project Directory: The main directory of your project should be mapped to the
/var/www/html
directory of the container. This is where the web server and the PHP interpreter will run your project safely and efficiently. -
Execution File: If the execution file of your project
index.php
is not in the/var/www/html
directory, you can define the directory of your project through theINDEX_PATH
environment variable. -
PHP Extensions: If your project requires additional PHP extensions or adjustments in the PHP settings, you can define the
PHP_EXTENSIONS
,MEMORY_LIMIT
, andUPLOAD_MAX_SIZE
environment variables as needed. -
Additional Processes: If you need to run more processes in addition to those existing in the image (for example, queues, workers, etc.), you can use the
SUPERVISOR_CONF
environment variable to indicate the path of the Supervisor configuration file. -
Viewing Logs: If you need to view the logs, they are located in the
/var/log
directory within the container.
By following these steps, you will be able to run your project in the Docker image Production efficiently and safely.
- PHP_EXTENSIONS: The PHP extensions to be installed. Default: null (e.g.: pdo_mysql mysqli)
- TIMEZONE: The timezone to be used by system. Default: UTC (List of Timezones)
- INDEX_PATH: The directory where the execution file of your project is located. Default: /var/www/html
- MEMORY_LIMIT: The memory limit that PHP can use. Default: 128M
- UPLOAD_MAX_SIZE: The maximum size of files that can be uploaded. Default: 8M
- SUPERVISOR_CONF: The path of the Supervisor configuration file. Default: null (e.g.: /var/www/html/supervisor.conf)
docker run -d -p 80:80 -v /path/to/your/project:/var/www/html -e PHP_EXTENSIONS="pdo_mysql mysqli" -e TIMEZONE=Europe/Lisbon -e MEMORY_LIMIT=256M -e UPLOAD_MAX_SIZE=16M -e INDEX_PATH=/var/www/html/public -e SUPERVISOR_CONF=/var/www/html/supervisor.conf production
services:
web:
image: production
ports:
- "80:80"
volumes:
- ./path/to/your/project:/var/www/html
environment:
- PHP_EXTENSIONS=pdo_mysql mysqli
- TIMEZONE=Europe/Lisbon
- MEMORY_LIMIT=256M
- UPLOAD_MAX_SIZE=16M
- INDEX_PATH=/var/www/html/public
- SUPERVISOR_CONF=/var/www/html/supervisor.conf
If you find any issues related to the image or have suggestions for improvements, do not hesitate to open an issue on GitHub. Please provide as many details as possible to assist in resolving the issue or implementing your suggestion.
If you need a Docker image for tasks such as environment setup, dependency installation, code compilation, or test execution, it is recommended to use a dedicated development image, use the image "Development". This was specifically designed to facilitate and optimize these tasks.
- João Pinto (Developer)
This project is licensed under the MIT license - see the LICENSE.md file for more details.